Updated

San Francisco, CA (SportsNetwork.com) - Matt Duffy's RBI single with two down in the bottom of the ninth capped a rally and sent San Francisco past Miami, 3-2, in the finale of a four-game set.

"Those guys in the ninth inning found a way. I thought it was huge win for us," Giants manager Bruce Bochy said.

Andrew Susac reached on a one-out single against Steve Cishek (1-2), and was replaced by a pinch runner. Gregor Blanco doubled and pinch-hitter Buster Posey drew a free pass to load the bases. Angel Pagan struck out, but Nori Aoki walked to force in a run.

Duffy followed by bouncing a ball through the left side to bring home Blanco with the winning run.

"It felt like a good pitch (to Duffy) with the fastball down and away," Cishek said.

Santiago Casilla (4-0) recorded the final two outs in the top of the ninth for the win.

Brandon Belt collected two hits and drove in the other run for the Giants, while Blanco doubled twice among his three hits.

Dee Gordon doubled twice and Michael Morse added two hits and knocked in a run for the Marlins.

Christian Yelich singled, stole second and scored on a Morse ground-rule double in the fourth to put the visitors on the board.

Aoki started the home sixth with a single, swiped second, moved up on a groundout and crossed home on Belt's base hit.

In the eighth, pinch-hitter Justin Bour singled with one down and Gordon doubled, then after Martin Prado fanned, pinch-runner Donovan Solano came in on a Sergio Romo wild pitch.

Miami failed to pad its lead, though, after Ichiro Suzuki walked and stole second to put two in scoring position. Marcell Ozuna grounded out harmlessly to first.

Game Notes

The win enabled the Giants to finish their 10-game homestand with a 7-3 record, while the Marlins fell to 3-4 on a 10-game road swing which sends them to Los Angeles starting on Monday ... Gordon has hit safely in 26 of his 29 games played this season and extended his hit streak to 13 games, raising his average to .439 ... San Francisco starter Ryan Vogelsong allowed a run on four hits with five strikeouts over seven innings ... Miami's Mat Latos also worked seven frames, yielding a run on seven hits while fanning five.