DENVER(AP) Ubaldo Jimenez had to pitch like an ace to beat Tim Lincecum , and that's exactly what he did.
Jimenez threw eight strong innings, outdueling Lincecum, and Seth Smith hit a two-run homer in the seventh that carried the Colorado Rockies past the San Francisco Giants 4-2.
''We knew what we were getting into when we came to the park,'' Smith said, referring to the pitching matchup. ''We knew what it was going to be like and it lived up to its billing.''
Jimenez looked forward to facing Lincecum but didn't worry about being compared to the 2008 NL Cy Young Award winner.
''I just leave that to everybody else,'' Jimenez said. ''I'm not thinking about if I deserve to be in Lincecum's league. I know he's one of the greatest pitchers.''
Held hitless by Lincecum for 5 1-3 innings, the Rockies rallied to move three games ahead of San Francisco in the NL wild-card race. Jimenez (12-9) won his sixth straight decision for Colorado, which has taken two of three in a four-games series that concludes Monday night at Coors Field.
Lincecum (12-4) was working on a no-hit bid in the sixth when Todd Helton singled off the glove of shortstop Edgar Renteria . Brad Hawpe walked with two outs and Ian Stewart 's RBI single cut the Giants' lead to 2-1.
Lincecum then walked Omar Quintanilla to start the seventh. After Jimenez's sacrifice bunt, Smith hit a 1-0 changeup into the second deck in right to give Colorado a 3-2 lead.
''Balls do weird things here and a changeup was left up and cut right back into his bat,'' Lincecum said. ''He put a great swing on it.''
Smith said he was looking fastball but was able to stay back to hit the changeup.
''When I hit it I knew I got it,'' he said.
Huston Street pitched a perfect ninth for his 33rd save in 34 chances.
In the first five innings, Lincecum wasn't always sharp, but he was effective. He walked three batters and hit another with a pitch but allowed only one runner as far as second base.
Early, his most troublesome inning was the second when he walked Hawpe and Chris Iannetta , but Quintanilla lined out to left to end the inning.
Lincecum allowed three runs and three hits in seven innings. He walked a season-high five and struck out seven.
''I was battling myself,'' he said. ''I was erratic and all over the place with the five walks and the hit batter. I just didn't know what was going on out there. I had a hard time finding it, but I still managed to get through the first five all right.''
Jimenez was sharp throughout. His only hiccup came in the second when he gave up a leadoff single to Ryan Garko and one-out homer to Renteria that gave San Francisco a 2-0 lead.
''He made one mistake all game,'' Iannetta said. ''He battled, he pitched out of every situation he got in and he gave us a chance to win.''
The Giants threatened to tie it in the eighth when Eugenio Velez led off with a double and moved to third on Randy Winn 's groundout. Jimenez got Pablo Sandoval to ground sharply to Helton at first for the second out, then retired Bengie Molina on a fly to left to end the inning.
''We had the right guys up,'' Giants manager Bruce Bochy said. ''We get a leadoff double, we moved him over and had our 3-4 hitters and Jimenez made some good pitches.''
Jimenez gave up six hits, struck out nine and walked two. It was the third straight game he has pitched eight innings and the 22nd consecutive start he has gone at least six.
''I think we'd be hard pressed to come up with a name of somebody on someone else's staff who's done that,'' Rockies manager Jim Tracy said. ''That's pretty special.''
The Rockies got an insurance run in the eighth. They loaded the bases with one out against reliever Jeremy Affeldt and, after Sergio Romo struck out pinch-hitter Garrett Atkins , he hit Clint Barmes with a 1-0 pitch to force in Troy Tulowitzki .
NOTES: Colorado OF Carlos Gonzalez was not in the lineup after sustaining a cut on his left hand. The Rockies said Gonzalez hurt himself when he caught a steak knife as it fell off a plate while he was putting a dish in the kitchen sink at home after Saturday's win. He needed one stitch to close the wound. Tracy said Gonzalez could be used as a pinch runner or defensive replacement Monday and could return to the lineup Tuesday or Wednesday. ... The Rockies signed RHP Russ Ortiz to a minor league contract. ... Giants 2B Freddy Sanchez (sore left shoulder) missed his sixth straight game and is doubtful for the series finale.