DENVER -- Kelby Tomlinson hit a one-out, tiebreaking single in the ninth and the San Francisco Giants rallied to beat the Colorado Rockies 3-2 on Tuesday night.
Eduardo Nunez had a solo homer in the third and a game-tying RBI groundout in the eighth.
Javier Lopez (1-2) got one out in the eighth to earn the win. Santiago Casilla pitched the ninth for his 31st save. He got Gerardo Parra to hit into a double play to end the game.
Buster Posey began the top of the ninth by hitting a grounder to shortstopDaniel Descalso, who overthrew first baseman Parra and allowed Posey to cruise into second. Hunter Pence followed with an infield single off closer Adam Ottavino (0-2), who was then replaced by lefty Boone Logan.
After Brandon Crawford struck out, Tomlinson lined an 0-2 fastball into left field to bring home Posey with the decisive run.
The Giants finished with eight hits, breaking a string of five straight games in which they have been held to four or fewer. The Giants are hitting .124 over their last six games.
DJ LeMahieu added a two-out, infield single in the third in which Raimel Tapiakept on running from second to score. Tapia also had a sacrifice fly in the fifth.
Tyler Anderson and Jeff Samardzija were locked in a pitcher's duel most of the game.
Anderson threw 7 1/3 crisp innings, giving up two runs and six hits. The lefty with a deceiving hitch in his delivery has a 3.04 ERA at Coors Field this season.
Samardzija matched the rookie's performance as he allowed two runs and four hits in seven innings. Samardzija struck out nine.
Anderson ran into trouble in the eighth by surrendering singles to Gorkys Hernandez and Trevor Brown. After a sacrifice bunt, Anderson was taken out for Jordan Lyles. Nunez grounded out to short to bring home the tying run.
Nunez's solo shot in the third was a rare homer for the Giants, who have 37 since All-Star break -- the second-fewest in the league.
LeMahieu, who is in a close race for the NL batting title with Washington'sDaniel Murphy, went 3 for 4 on Tuesday and raised his average to .343.
Giants: RHP Jake Peavy (strained lower back) threw a bullpen session Monday and could be activated off the DL on Wednesday. ... Manager Bruce Bochy gave INF Joe Panik and OF Denard Span a night off.
Rockies: OF Charlie Blackmon missed a fourth straight game with tightness in his lower back. "He's definitely closer," manager Walt Weiss said. ... OF Ryan Raburn's bruised left foot remains sore, Weiss said.