(AP) Jeff Mathis hit an early home run, then lined a tiebreaking double in the eighth inning that bounced off Giants center fielder Andres Torres and sent the Miami Marlins over San Francisco Giants 6-5 Sunday.
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.
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.
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.
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.
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.
NOTES: Marlins 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).