The result knocked the Rockies a game behind the National League West-co-leading Giants and D-backs. But the Rockies' next four games -- on the road Monday and Tuesday, at home Wednesday and Thursday -- are against the Astros, whose 14 wins are second-fewest in the Majors.
Sunday wasn't the first time this season the Rockies let Cain (4-2) off the hook. On May 16, the Rockies built a 6-0 lead against Cain at Coors Field, only to lose, 8-6. On Sunday, Cain walked the bases loaded with one out in the first, then gave up Michael Cuddyer's two-run double.
But Cuddyer's hit accounted for one of only two the Rockies managed off Cain, who finished with six strikeouts and dominated once he made it back into the strike zone.
"It's hard when you have a lot of situations in front of you and you're not able to do anything," said Rockies left fielder Carlos Gonzalez, who struck out twice against Cain and three times overall during an 0-for-5 performance. "I left a lot of runners on base. We all did."
Cuddyer's double and pinch-hitter Jordan Pacheco's RBI single in the eighth were the Rockies' only hits in 16 at-bats with runners in scoring position. Cain -- 17-7 in 30 career starts against the Rockies -- was responsible for much of that.
"That game was all about Matt Cain and him settling down to give us five innings," Giants manager Bruce Bochy said.
After Cuddyer's first-inning double, Todd Helton was left kicking himself after striking out on a high fastball.
"I sort of set my sights down low and just bit on it," Helton said.
Cain ended the first by working Wilin Rosario into a liner to left. Cain walked DJ LeMahieu and Dexter Fowler in the second, but induced a Nolan Arenado flyout to center and struck out Gonzalez for the second time.
"He found his breaking ball somewhere along there -- I think about the third inning -- and he was throwing strikes with it," Rockies manager Walt Weiss said.
Also, the game ended with fears about Cuddyer, who returned from a neck injury at the start of the series and went 4-for-11 with a home run, three doubles and six RBIs, but exited in the sixth inning. He was hit in the right forearm by Giants pitcher George Kontos and left the game after running the bases, but X-rays were negative, and the Rockies announced he had a right forearm contusion.
Still, Cuddyer, whose forearm was wrapped heavily in the clubhouse afterward, was not sure he could play Monday and wasn't totally sure he could avoid a return to the disabled list.
"It's swollen, sore, stiff, all that," Cuddyer said.
Buster Posey opened the second with his seventh home run of the season, off Rockies starter Jon Garland (3-6), and the Giants tied it in the fourth on Brandon Crawford's fielder's choice.
Garland gave up seven hits and threw 102 pitches in five innings. But his pitch count was elevated by two unusual plays with two out, one of which hurt.
In the second, Rockies shortstop Troy Tulowitzki caught one of his spikes in the dirt and tripped while fielding Cain's grounder with two on. Cain reached to load the bases, but Garland induced a Gregor Blanco ground ball.
With the score tied at 2 and one on in the fifth, LeMahieu, fighting the sun and wind in short right field, lost Hunter Pence's fly ball for an error. Brandon Belt doubled in two runs, and Andres Torres doubled Belt home for a 5-2 lead.
"When it went up with the wind -- I saw other people catching fly balls -- I knew it wasn't going to stay straight, and once it got above the stadium, the wind took it," LeMahieu said. "I tried to keep my feet moving, but I misjudged it completely."
Garland felt he made progress and would have done better had a few pitches been called his way early, but that didn't trump the fact he lost for the fifth time in his past six decisions.
"It's tough when you put your team down three and you end up losing the game to sit and say that you made strides," Garland said, "but to a certain degree, yeah."