SAN FRANCISCO — Buster Posey hit a two-run homer and Matt Cain bounced back from two rough starts to earn his first win in more than a month as the San Francisco Giants beat the first-place Arizona Diamondbacks for a second straight night, winning 4-3 on Saturday.
Posey connected for his 14th homer in the fifth inning. Cain (6-6) allowed two runs in five-plus innings after failing to make it out of the third inning his last two starts to win for the first time since June 13 at Pittsburgh.
With wins in the first two games out of the All-Star break, the World Series champion Giants have cut their deficit in the NL West to 4½ games behind Arizona. The Diamondbacks' lead over the Los Angeles Dodgers fell to a half-game as Wade Miley (6-8) lasted just four innings and All-Star Paul Goldschmidt failed to deliver in a key spot for the second straight game.
Cain was coming off two disastrous starts before the All-Star break. He gave up eight runs and was knocked out in the third inning of a loss to the Dodgers on July 5 and retired only two batters and gave up three runs to the Mets five days later in his shortest career start.
But Cain looked sharp early, striking out two batters in the first and not giving up a run until the fifth when shortstop Tony Abreu threw the ball into the stands behind first while trying to complete a potential inning-ending double play.
Cain escaped further damage when he got Paul Goldschmidt to ground out with the bases loaded to end the inning. It was the second straight game that the Giants got their nemesis to ground out with the bases loaded. Goldschmidt has the most homers and RBIs against San Francisco over the last three seasons.
Cain was replaced after allowing back-to-back singles to Aaron Hill and Miguel Montero to open the sixth. Martin Prado followed with an RBI single off George Kontos to cut San Francisco's lead to 4-2. Kontos, Jeremy Affeldt and Jose Mijares each retired a batter to escape the inning with no further damage on the scoreboard. But Affeldt left the game with a strained left groin when he came up lame on a pitch to pinch-hitter A.J. Pollock.
San Francisco used seven relievers to get through the final four innings Sergio Romo pitching the ninth for his 23rd save in 26 chances. Romo allowed a two-out RBI single to Prado ending a streak of 29 consecutive scoreless outings against Arizona before striking out Cody Ross to end it.
The Giants gave Cain an early lead to work with when Pablo Sandoval drove in Marco Scutaro with a two-out double in the first inning and appeared to be on the verge of breaking the game open in the fourth when they had the bases loaded and one run in before Miley escaped the jam.
Posey, Sandoval and Hunter Pence opened the fourth with consecutive singles to load the bases. Jeff Francoeur drew a bases-loaded walk to make it 2-0 but that was all the Giants would get. Sandoval was thrown out trying to score from third on a pitch to the screen and Pence was thrown out on Abreu's grounder to Prado at third. Miley then struck out Guillermo Quiroz to keep the score 2-0.
NOTES: Arizona has lost 12 of 15 road games. ... Giants RHP Ryan Vogelsong (broken finger) threw 33 pitches in a simulated game and could be ready to begin a rehab assignment Tuesday in the Arizona Rookie League. ... All-Star Madison Bumgarner (10-5) starts for the Giants in the series finale on Sunday against Randall Delgado (1-3).