Gregor Blanco went 2-for-4 with a two-run triple as the San Francisco Giants defeated the Miami Marlins, 6-4, in the middle test of a three-game set.
Pablo Sandoval also knocked in two runs and Andres Torres had an RBI for the Giants, who have won three straight.
Matt Cain (8-8) gave up a home run -- a two-run shot by Giancarlo Stanton -- plus three hits and a pair of walks over seven innings to earn the win. The 28-year-old right-hander has allowed three earned runs or less in his last seven starts.
"I felt good," Cain said. "We were letting the defense work and then they were able to put up four runs in that one inning which was big to get a lead and keep it moving that way and keep the momentum on our side is always beneficial as a starter."
Henderson Alvarez (2-2) got the start for the Marlins and also went seven innings. He gave up four runs on four hits and four walks.
The Giants scored four runs in the fourth to take the lead. Brandon Belt drew a one-out walk and Buster Posey singled to center before both advanced on a wild pitch as Hunter Pence struck out. Sandoval scored Belt with an infield single, but he collided with Miami first baseman Logan Morrison and Alvarez as he slid to first. Sandoval was shaken up, but all three players remained in the game.
A balk by Alvarez allowed Posey to cross home and after Roger Kieschnick walked, Blanco drove in two runs with a triple to center to give the Giants a 4-0 lead.
"We kind of gave that one away," Marlins manager Mike Redmond said. "We didn't execute and that cost us."
Stanton got the Marlins on the board when he crushed a two-run homer in the sixth. Donovan Solano hit a leadoff single prior to the shot.
San Francisco added two more runs in the eighth. Miami reliever A.J. Ramos walked Brandon Crawford, Belt and Posey with one out before being replaced by Mike Dunn. However, Dunn walked Sandoval to allow Crawford to score. Pinch- hitter Andres Torres then plated Belt with an infield single.
Miami answered in the home half. With Santiago Casilla pitching for San Francisco, Christian Yelich walked to start the frame. Solano grounded into a fielder's choice, but a throwing error by Crawford allowed Yelich to reach third. After Stanton struck out, Morrison knocked a two-RBI double to right.
However, Casilla was able to stop the rally by striking out Ed Lucas and getting Adeiny Hechavarria to fly out.
Sergio Romo threw a 1-2-3 ninth to notch his 30th save.
Cain has a 2.41 ERA since the All-Star break. However, he has allowed 19 home runs this season, tied for fifth-most in the National League ... Belt went 0- for-2 with two walks, which snapped 11-game hit streak ... Stanton's last home run came on July 28 ... San Francisco's Madison Bumgarner is scheduled to face Miami's Tom Koehler in Sunday's series finale.