MIAMI (AP) -- A bad bounce brought a bit of good fortune to the Miami Marlins.
Jeff Mathis hit an early home run, then lined a tiebreaking double in the eighth inning that deflected off Giants center fielder Andres Torres and sent Miami over San Francisco 6-5 Sunday.
"You definitely a little bit of luck there today for us," Marlins manager Mike Redmond said. "We scored a couple a couple runs on some wild hops and a wild pitch, but hey, we'll take it."
It was 5-all in a back-and-forth game when Ed Lucas led off the eighth with a single against Sandy Rosario (3-1). With one out, Mathis hit a liner to left-center and the ball dropped in front of Torres' dive and caromed off him.
"When I was getting ready to dive, my foot kind of got stuck in the ground and I missed the ball," Torres said. "It just got away from me and kept rolling."
Lucas scored on the play.
"It's incredibly cliche to say, but sometimes the ball bounces your way," he said.
Chad Qualls (4-1) pitched 1 1-3 scoreless innings and Steve Cishek worked the ninth for his 27th save in 29 chances.
Hector Sanchez singled with one out in the ninth before Buster Posey grounded into a game-ending double play.
Hunter Pence homered and drove in three runs, Brandon Crawford also hit a home run, and Gregor Blanco had three hits for the Giants.
Miami starter Tom Koehler allowed three runs and seven hits in five innings.
Crawford led off the seventh a home run against Mike Dunn, tying it at 4. Sanchez hit a go-ahead double later in the inning that put the Giants ahead.
"Anytime you lose a lead it's a little deflating," Mathis said.
Guillermo Moscoso, who struck out the side in the sixth, allowed an RBI double by Donovan Solano in the seventh to tie game at 5.
Pence broke his home run drought with a two-run drive in the first. It was his first home run since July 13 at San Diego, a span of 111 at-bats.
"The focus is on each individual at-bat, so when you don't (hit a home run) for a long time that can be frustrating, but it doesn't change the constant of being ready for the next at-bat and the next at-bat after that and trusting that eventually it will happen," Pence said.
Mathis hit a solo home run in the third off Madison Bumgarner to cut the Marlins' deficit to 2-1.
Back-to-back RBI singles by Lucas and Adeiny Hechavarria in the fourth gave Miami a 3-2 lead.
"It seemed like every pitch I threw today was just a hair off and in the wrong direction," said Bumgarner who allowed four runs in give innings. "It was just kind of frustrating for me today."
Pence tied it a 3 with an RBI single in the fifth, his eighth RBI in the three-game series.
Miami regained the lead at 4-3 in the fifth on a wild pitch by Bumgarner.
"There were balls bouncing everywhere today," Giants manager Bruce Bochy said. "We gave up too many runs and missed a couple of good opportunities. The wild pitch there that we allowed a run to score on, and the bounce off Andres. ... We let this one get away, the way I look at it."
NOTES: The home run sculpture in the outfield got jammed and did not go off after Mathis' home run. ... Since 2010, Blanco is hitting .470 (31 for 66) with five doubles, three triples, and eight RBIs in 18 games against the Marlins. ... Miami RHP Jose Fernandez (8-5, 2.45 ERA) will face fellow Cuban phenom Yasiel Puig for the first time on Monday when the Los Angeles Dodgers arrive in Miami for a four-game series. "I'm going to try to get him out, and he's going to try to get a hit against me," Fernandez said. "It's going to be a good battle and the fans are going to love it." The Dodgers will counter with LHP Hyun-Jin Ryu (12-3, 2.91 ERA).
Copyright 2013 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.