SAN FRANCISCO — Bengie Molina homered twice, Pablo Sandoval had four hits and the San Francisco Giants kept their slim wild-card hopes alive with an 8-4 win over the Arizona Diamondbacks on Tuesday night.
Molina hit a two-run homer off Doug Davis in the fourth and followed Sandoval's two-run shot in the seventh with a solo drive off Leo Rosales.
The Giants trail wild card-leading Colorado by five games with five left on their schedule. The Rockies beat Milwaukee 7-5 in 11 innings.
Miguel Montero homered twice, including a two-run drive into McCovey Cove in the sixth, for Arizona.
Molina, playing in what could be his last home series with the Giants, had one of his best nights at the team's waterfront stadium after sitting out the previous three games with bruised fingers on his left hand. San Francisco's popular catcher matched his season high with four RBIs and went deep twice for the second time this year, giving him a career-high 20.
Molina, 35, is eligible for free agency this offseason. The Giants need to add more offense and have 2008 first-round draft pick Buster Posey, who hit .325 with 18 home runs and 80 RBIs in the minors this year, waiting to take over behind the plate.
Sandoval had two singles, a double and his 23rd homer to raise his average to .329. He also scored four times.
Jonathan Sanchez (8-12) retired 11 of the first 13 batters he faced before yielding Montero's two-run homer in the fourth. The next batter, Ryan Roberts, then hit what was initially ruled a homer before umpires, using instant replay, changed it to a ground-rule double.
Left fielder Andres Torres appeared to catch the ball after leaping at the fence, but it popped out of his glove and landed on top of the wall momentarily before dropping off. Torres, who had fallen on his back on the warning track, reached up and grabbed the ball out of the air but third base umpire Dana DeMuth signaled home run.
Giants manager Bruce Bochy came out to protest and the umpiring crew left the field briefly to view the replay before returning and changing the call to a double. Sanchez then retired Rusty Ryal to end the inning.
Sanchez allowed three runs and five hits in 5 1-3 innings. Bob Howry, Dan Runzler, Jeremy Affeldt and Sergio Romo combined to finish the seven-hitter.
Montero's towering drive in the sixth was the first hit into McCovey Cove by a Giants opponent this season and cut San Francisco's lead to 4-3. Montero picked up his first multihomer game of the year and third of his career.
Sandoval doubled leading off the bottom half and scored on a single by Molina.
Davis (8-14) beat San Francisco a week earlier when he went 7 1-3 innings but the left-hander wasn't nearly as sharp this time. He gave up seven hits and walked five in four innings while losing for the sixth time in his last eight starts.
Eugenio Velez scored on a wild pitch in the first and Aaron Rowand drew a bases-loaded walk to give the Giants a 2-0 lead.
SHORT HOPS: The Diamondbacks fell to 2-8 at AT&T Park this season. ... Sanchez is 3-1 with a 2.59 ERA in five starts and one relief appearance against Arizona in 2009. ... Roberts is batting .400 (10-for-25) over his last eight games. ... Davis singled in the third, his 10th hit of the year.