Gregor Blanco knocked in the go-ahead run with a perfectly placed safety squeeze in the top of the 10th inning and the San Francisco Giants edged the Philadelphia Phillies, 6-5, in the middle installment of a three-game series.
With Jonathan Papelbon (2-4) on the mound, Melky Cabrera drew a leadoff walk and Buster Posey blooped a single into right -- his fourth hit of the game -- to put runners on the corners. After Pablo Sandoval fanned, Blanco pushed a bunt up the first base line that could not be handled by Ryan Howard, allowing Cabrera to score.
Sergio Romo (3-1) picked up the win with two-thirds of an inning of scoreless relief and Santiago Casilla worked around a walk in the bottom of the 10th to nail down his 24th save of the season.
Despite the two teams trotting out pitchers Matt Cain and Cole Hamels, the game unexpectedly turned into a home run derby. The Giants and Phillies combined to hit six home runs and each starter contributed a long ball.
It was the first time a pair of starters homered off each other in the same inning since Fernando Valenzuela and Kevin Gross did it on May 14, 1990.
"It certainly wasn't the type of game we thought it would be," Giants manager Bruce Bochy said. "It's not too often you see both pitchers go deep. Both teams threw out some good at-bats, both pitchers made some mistakes and paid for them."
On the mound, Cain allowed five runs on five hits and two walks with four strikeouts over eight innings.
Hamels, who is set to become a free agent at the end of the season and may have made his last home start in a Phillies uniform, gave up five runs on 10 hits with six strikeouts and three walks.
"I have to make one pitch, I have to try to execute, I have to try to win the ballgame," Hamels said when asked about his status with the team. "That's ultimately what I try to stick to no matter what. Those types of thoughts are always going to be after the fact or after the game when I'm not playing. But when I'm playing, it's 100 percent, everything I have."
Posey, Cabrera and Cain homered for the Giants, winners in seven of their last eight, while Hamels, Howard and Chase Utley hit round-trippers for the Phils, who have dropped three straight.
The Phillies opened the scoring in the first inning when Utley tagged a fastball down-and-in from the Giants righty and smoked it off the facing of the second deck for the 1-0 lead.
The Giants took the lead with a pair of long balls in the third. Cain got a cutter down the heart of the plate and sent it over the wall in left to tie the game. Cabrera drew a walk three batters later and Posey went down and got a changeup, sending it deep and into the left field stands to put San Francisco up, 3-1.
Hamels answered Cain's shot with one of his own in the home third when he ripped a fastball into the right-field seats for his first career long ball, pulling Philadelphia within 3-2.
Posey knocked home Ryan Theriot with an RBI single in the fifth to extend the lead to 4-2, but the Phillies went ahead in the sixth.
Jimmy Rollins walked to start the frame and Shane Victorino blooped a single into right. After Utley flied out, Howard got a fastball from Cain and smashed it deep over the wall in right-center, making it 5-4.
The Giants quickly tied the game again in the eighth when Cabrera led off the inning by taking Hamels deep and just inside the left-field foul pole.
Victorino collected his 1,000th career hit. He became the first Hawaiian-born player to reach the milestone...The Giants improved to 7-1 since the All-Star break and 7-1 in extra-inning games...It was Cain's sixth career home run...Hamels' shot in the third was his first career long ball...Giants outfielder Angel Pagan was ejected by home plate umpire Mike Everitt in the sixth inning...Cain allowed three home runs in a game for the first time since October 1, 2010 against the San Diego Padres...Philadelphia fell to 2-9 in extra innings.