DENVER (AP) — The San Francisco Giants headed home with their playoff hopes still alive.
Pablo Sandoval homered twice in an eight-run fourth inning, part of a six-home run barrage that led the late-charging Giants over the Colorado Rockies 12-5 Sunday for their eighth straight win.
On its longest winning streak since April 2007, San Francisco closed within four games of Atlanta, the NL wild-card leader.
"We've done what we needed to do," manager Bruce Bochy said. "It's obvious we need help. We've got to find a way to get (wins) and see what happens at the end."
Pitcher Matt Cain, Mike Fontenot, Brandon Belt and Brandon Crawford also homered for the Giants, who remained five games back of Arizona in the NL West.
The defending World Series champions have nine games left, including three against the Diamondbacks.
"We feel like we've got a really good shot," Belt said.
Cain (12-10) allowed five runs — three earned — five hits, four walks and two hit batters in five innings. He helped himself with two hits, including his first home run since May 13, 2008, against Houston.
"I never found a rhythm," he said. "I was really working and putting a lot of pressure on myself throughout the five innings."
Bochy said he was one batter from taking Cain out in the fifth, but Cain got Tommy Field to hit into an inning-ending double play.
"He looked like he didn't know how to pitch with a lead like that," Bochy said.
In a four-game sweep of the Rockies, the Giants piled up 35 runs and 48 hits. Sandoval led the way with a seven hits, including three homers, in three games. He started the series by hitting for the cycle Thursday and ended it with his second multihomer game this season.
"What a series he had," Bochy said. "Pretty impressive. Pablo was locked in."
Sandoval led off the fourth with a homer to center off Esmil Rogers (6-6). One out later, Belt homered and Crawford doubled. Cain followed with a homer to center.
Sandoval ended the rally with his 22nd homer, a drive into the right-field bleachers for 10-1 lead.
"I said to my teammates, 'I got the hard ones. We'll see what happens.' When you get the hard ones, it's tough to get the easy ones," Sandoval said. "I wasn't thinking about the cycle, you just want to get a pitch to drive the guy in. I got a good pitch, and I hit a home run."
Fontenot had given the Giants a 2-0 lead with a two-run homer in the first.
Colorado scored twice each in the fourth and fifth innings to close the gap, but a solo homer by Crawford helped the Giants stay comfortably ahead.
Ty Wigginton and Seth Smith had two hits each for Colorado, which has lost five of six.
Rogers allowed nine runs and seven hits in 3 2-3 innings, dropping to 0-4 with a 7.81 ERA since winning three straight starts in late July and early August.
"The ball was very true going through the strike zone and somewhere between belt and mid-thigh area," Rockies manager Jim Tracy said. "When you do that, you're going to get hit by good big league hitters. That's exactly what happened."
NOTES: The Giants activated closer Brian Wilson from the 15-day DL. ... The previous San Francisco player to homer twice in the same inning was Juan Uribe last Sept. 23 against the Chicago Cubs. ... The last time the Giants hit four home runs in one inning was Aug. 23, 1961, at Cincinnati. They last hit six homers in one game Aug. 7, 2006, at Arizona. ... The Giants open a three-game home series against the Dodgers on Tuesday. Two-time NL Cy Young Award winner Tim Lincecum will face Clayton Kershaw in the opener. ... Colorado finishes its home schedule with a three-game series against San Diego starting Monday.