PHOENIX -- The Arizona Diamondbacks finally got to celebrate after their last at-bat.
"We hadn't felt that feeling in a while," manager A.J. Hinch said, "and that was a perfect way to end the slide."
Arizona was just back from a franchise-worst 0-9 trip, the last four of the losses coming in its opponent's final at-bat.
"The main deal is not the base hit tonight for me," Roberts said. "The main deal is to get the win."
Gerardo Parra set up Roberts' winning hit with a tying single, driving in Edwin Jackson from second. The starting pitcher came in to run after closer Manuel Corpas (1-3) hit Mark Reynolds on the left hand with a pitch.
Hinch said Reynolds was hit on the pinkie and was not seriously hurt. He said he was going to have Jackson run for him regardless because Reynolds is nursing a sore right quadriceps.
Roberts' single came on the first pitch and drove in Chris Young from second.
"C.Y., he's a good runner," Roberts said. "All I had to do is put the ball in play and let it get to the outfield. Everything else will take care of itself."
Stewart hit a tiebreaking three-run shot in the sixth to make it 6-3. The three runs were unearned after second baseman Kelly Johnson's error.
"Actually we were trying to steal that game because we really didn't do a whole lot to win it," Colorado manager Jim Tracy said. "We didn't play well enough to win it. We did some things at least to get ourselves to a point where we had an out in the bottom of the ninth and they still managed to get us."
Young connected in the bottom half of the sixth and Reynolds hit his second sacrifice fly of the game in the seventh to get the Diamondbacks within one.
Arizona looked as if it was headed for another heartbreaker after loading the bases with one out in the eighth and failing to score. Rafael Betancourt came on to strike out Upton and Stephen Drew to end the inning.
"Going into the ninth inning we were going to talk about 10 runners left on base and a couple of strikeouts with runners in scoring position," Hinch said. "How quickly things can change."
Gonzalez kept up his season-long success against Arizona, hitting Ian Kennedy's 0-2 pitch over the wall in center for a game-opening homer. Five of Gonzalez's eight homers have come against the Diamondbacks. He also has two doubles, a triple, four singles and 12 RBIs against Arizona this year.
The Diamondbacks' string of 31 consecutive scoreless innings ended with Upton's two-run homer in the bottom half.
All four of Gonzalez's game-opening homers have come against Arizona, two this season. ... The Rockies swept Arizona in Colorado to start the D-backs' 0-9 trip. ... Drew is tied for the major league lead with five triples. ... Arizona pitchers struck out 14, five by Esmerling Vasquez, whose two-out balk in the ninth lost a game in Los Angeles on Monday.