SAN FRANCISCO -- Andres Torres talks himself into a positive state of mind no matter the circumstance. This year, it's paying dividends.
Torres led off the eighth inning with a go-ahead home run, helping the San Francisco Giants beat the Colorado Rockies 5-2 on Tuesday night to close within four games of the NL West-leading San Diego Padres.
|More on Rockies|
"I try to think something positive every time out," Torres said. "I reminded myself to go out and swing hard and stay loose. Every game from now on is going to be important."
Buster Posey added a two-run double in the eighth as the Giants won for the second time in six games. Freddy Sanchez had two hits and scored twice.
Melvin Mora hit a tying homer and Clint Barmes drove in a run for the Rockies, who had their three-game winning streak snapped.
Jeremy Affeldt (4-3) blew a late lead for the second straight game but earned his second consecutive win after pitching the eighth. Brian Wilson worked the ninth for his 37th save.
Matt Belisle (6-5) gave up a run in his third consecutive appearance after not allowing any in his previous 14 outings.
"You overthink things like this and you dig yourself a bigger hole," Belisle said. "I've been through stuff like this before. The main thing is to maintain my aggression and get right back out there."
Giants starter Madison Bumgarner is still looking for his first win at home after allowing a run and five hits over six innings. He walked three and struck out two.
"They're creeping back into the race and we need to pull away from them again," Bumgarner said. "It felt good to go out there and pitch well."
Bumgarner, winless in six home starts, gave up eight runs in 2 2/3 innings in his last start.
"Madison did a great job of keeping us in the game," Posey said. "He pounded the zone. That was a big boost for us."
Rockies starter Esmil Rogers went six-plus innings, allowing two runs and four hits. He walked two and struck out three.
"We did a terrific job and created some opportunities for ourselves," Rockies manager Jim Tracy said. "Andres Torres, obviously, was the big at-bat, hitting a 3-2 pitch out of the park. They just beat us."
Sanchez doubled with one out in the first, went to third on a groundout by Aubrey Huff and scored on a balk by Rogers, who fumbled the ball during his delivery after getting his spike caught in his shoelace.
The Rockies loaded the bases with one out in the second, with Mora and Ryan Spilborghs each drawing a walk ahead of Miguel Olivo's single. Barmes hit a sacrifice fly to tie it at 1.
With two outs in the fifth, Juan Uribe singled and scored on Bumgarner's double to give the Giants a 2-1 lead.
"My first at-bat I was guessing wrong on every pitch," Bumgarner said. "So I just looked for the fastball and got it. I might have gotten lucky on that."
Mora's two-out homer in the eighth tied it for the Rockies, who rallied from a 1-0 deficit in the ninth to beat the Giants on Monday night.
"That was kind of a gut-check," Posey said. "Guys came back and fought hard. That's what we're going to have to do."
Bumgarner got his first career extra-base hit. ... Sanchez extended his hitting streak to eight games with his first-inning double. ... The Rockies acquired RHP Manny Delcarmen from Boston for minor league pitcher Chris Balcom-Miller. ... Giants starters were 5-13 with a 5.13 ERA in August.