PHOENIX — Colorado manager Walt Weiss thought he had the right reliever on the mound for a shutdown inning after the Rockies had just taken the lead in the top of the sixth. But things didn’t go as planned.

Yasmany Tomas hit his first career grand slam, and the Arizona Diamondbacks came back from a three-run deficit after squandering a five-run cushion to beat Colorado 12-9 on Monday night.

Tomas homered off Jordan Lyles, and Arizona never looked back.

“We wanted to go to him in the sixth because it was the teeth of their lineup and we had just scored,” Weiss said. “I thought it was important to get a zero right there.”

Brandon Drury had four hits for the Diamondbacks, including a solo homer in the seventh.

Lyles (4-5) got the first two outs of the sixth. Then he gave up consecutive singles to Drury, Paul Goldschmidt and Welington Castillo before Tomas connected.

“With Tomas, I tried to go down and away but I didn’t make my pitch,” Lyles said. “He put a good swing on it. It was just where I wanted to stay away from, is where it ended up.

“I didn’t do my job tonight. Up three runs, I’ve got to get out of that inning still with the lead and I didn’t,” he added.

Mitch Haniger’s first major league home run also came in the Diamondbacks seventh. Randall Delgado (4-1) was credited with the win despite retiring only one of the four batters he faced in the sixth, and Daniel Hudson earned his third save.

Arizona, with 16 hits on Monday, has 10 or more in 12 consecutive games against the Rockies. That makes the Diamondbacks the first NL team since the 1932 Brooklyn Dodgers to have a 12-game streak of 10-plus hits against a single opponent in one season.

Daniel Descalso homered and drove in three runs, and Carlos Gonzalez doubled three times and added three RBIs for the Rockies. Colorado’s 15 hits included four for Gonzalez and three for Nolan Arenado and Charlie Blackmon.

Arenado’s two-run single in the sixth gave Colorado a 9-6 lead after Descalso opened the inning with a solo shot. The Rockies trailed 5-0 going into the fourth.

“Charlie and DJ (LeMahieu) have been getting on base and doing their thing most of the year if not all year,” Weiss said. “When they do that and Nolan and CarGo are swinging the bats, we will score some runs like we did tonight. But you’ve got to keep them from scoring, too.”

Blackmon got his 200th career extra-base hit. Gonzalez has a nine-game hitting streak at Chase Field, and Descalso has homered in three of his last four games against Arizona.

Diamondbacks starter Shelby Miller helped himself with the bat, doubling and scoring on a sacrifice that resulted in pitcher Tyler Anderson’s throwing error in the fourth. But the Rockies drew even at 6 in the fifth on Gonzalez’s two-out, two-run double followed by a soft single by Raimel Tapia that scored Gonzalez.

That was all for Miller, who started strong by getting the first nine outs in order but ended up allowing six runs on nine hits.

Anderson yielded five earned runs and nine hits in 4 1/3 innings, the second time in 17 starts this season he failed to pitch five innings. He struck out seven and walked two.

JUMPING RIGHT IN

Arizona native Will Claye, the triple jump silver medalist at the Rio Olympics, attended the game and caught one of three pitching-machine pop flies during a between-innings break.

STREAKING

LeMahieu had two hits and reached base safely for the 29th consecutive game, a career high.

TRAINER’S ROOM

Diamondbacks OF A.J. Pollock appears to be ahead of schedule in his recovery from a groin strain and could return to the lineup before the season ends.

UP NEXT

Rockies: LHP Jorge De La Rosa (8-7) is set to face the Diamondbacks for the fourth time this season. He has one win in those three previous outings.

Diamondbacks: LHP Robbie Ray (7-13) makes his seventh career start against Colorado on Tuesday.