PHOENIX -- Miguel Montero took two mighty swings, trying to end the game on both. He failed, so for the third, he shortened up, trying to protect the plate.
That ball ended up going out and, boy, did the Arizona Diamondbacks need it.
Montero hit a leadoff homer in the 10th inning after Martin Prado hit a two-run single in the ninth, helping the Diamondbacks end a four-game losing streak with a 5-4 win over the Colorado Rockies Wednesday night.
"I was swinging hard, trying to launch one," Montero said of his first two swings. "It's a pretty funny game. It was the last pitch I was thinking about in that count and it was a short swing, I was kind of quick on it. That protect swing was pretty good."
And a good thing for the Diamondbacks.
Stuck in a rut, Arizona appeared to be in trouble after Colorado went up 4-0 after three innings on Carlos Gonzalez's two-run homer and pitcher Jordan Lyles' leadoff shot in the third.
It took some time, but the Diamondbacks worked their way back into it.
After struggling early, Josh Collmenter quieted the Rockies' bats over his final four innings and Trevor Cahill did the same while getting six outs.
Paul Goldscmidt gave Arizona's offense a little life in the eighth inning, hitting a solo homer off Adam Ottavino.
In the ninth, the Diamondbacks strung together a string of two-strike hits to load the bases against Rex Brothers, and Prado tied it at 4 with a two-run single up the middle.
Addison Reed (1-2) kept the Rockies in check by stranding a runner at third in the 10th inning and Montero, after a couple of misses, ended it with his first career walkoff hit, a towering homer to right off Tommy Kahnle (2-1).
Montero was mobbed as he crossed the plate and was treated to a dirt bath -- an Arizona walkoff tradition -- that was a nice release for a team that had won two of its first 13 games at Chase Field.
"We needed that," Arizona manager Kirk Gibson said. "It was good that the guys hung in there."
The Rockies certainly didn't want to end their six-game road trip this way.
Colorado won four of the first give games and appeared to be in control after Lyles pitched six effective innings.
But the Rockies lost the lead after Brothers struggled to put away hitters and the game when Montero hit a 1-2 fastball over the wall.
Nolan Arenado extended his majors-best hitting streak to 20 games with a single in the sixth inning for Colorado, which had three hits after the third inning.
"We had the game in control it looked like for most of the game, so it was a tough one to lose," Rockies manager Walt Weiss said. "It is always tough when you don't put games away."
The Rockies beat up on Arizona's pitching the first two games of the series, with 13 runs and 23 hits, including 12 for extra bases.
They kept it up early against Collmenter -- with a little help from the right-hander.
Gonzalez got it going in the first inning, eking a two-run homer just over the wall in the right.
Collmenter had a wild pitch to advance Jordan Pacheco to third in the second inning, but got a break when he was called out on appeal for leaving the base too early on a fly to right.
Lyles led off the third with his first homer on Sept. 30, 2012, with the Astros at Milwaukee, and Collmenter followed with another wild pitch that scored Charlie Blackmon to put Colorado up 4-0.
Collmenter settled in after that, retiring 10 straight batters until Arenado's two-out single in the sixth inning.
Collmenter allowed four runs on seven hits in seven innings.
"He really started getting the ball down, locating better, getting his curveball down," Gibson said. "He was much more effective and to throw seven innings like that was really what we needed."
That kept the Diamondbacks in it, but they couldn't get much going against Lyles.
Prado hit a one-out triple off Lyles in the first inning, but was thrown out at the plate trying to score on a grounder by Goldschmidt.
Arizona loaded the bases against Lyles in the sixth, scoring just one run, on Aaron Hill's groundout. The Diamondbacks struggled in a similar situation the night before, failing to score with the bases loaded and no outs in a 5-4 loss to the Rockies.
Unlike the night before, Arizona found a way to win it when Brothers couldn't put hitters away, particularly Prado, who's tying hit came with two strikes.
"One pitch away from that game being in the books. No doubt about it," Brothers said. "I didn't execute. Bottom line. I didn't execute a pitch."