SAN FRANCISCO (AP) -- Miami Marlins manager Mike Redmond has no explanation for why his club has played so well at home and struggled so much on the road this season.
Wins like Friday night will help erase those questions.
Casey McGehee singled home the winning run with one out in the ninth inning to atone for a costly error and help the Marlins earn a rare road win, 7-5 over the San Francisco Giants.
''I think we're still trying to figure it out,'' Redmond said. ''If I had an answer to why we're so much better at home to on the road, we'd fix it, right? But these guys keep battling. They keep fighting. You saw that tonight. We don't quit. We keep grinding. We might make a few mistakes, but we keep going.''
The Marlins made plenty of mistakes. They also made some big plays, too.
Derek Dietrich and Christian Yelich homered, and Jarrod Saltalamacchia snapped an 0-for-26 skid by tying his career high with four singles to stop Miami's slide. The Marlins entered the game losers of six of their past seven games and a majors-worst 4-16 record away from home.
They also are a league-best 17-5 at home.
''We've seen those games go the other way sometimes, especially on the road right now. It was huge for us to be able to stick in there and get that one,'' McGehee said.
Santiago Casilla (1-1) got out of a bases-loaded jam in the eighth, but couldn't escape trouble in the ninth. The right-hander allowed two baserunners before McGehee's tiebreaking grounder to right field.
''It just had eyes and got through the infield,'' Giants manager Bruce Bochy said. ''That's the way the game goes.''
Garrett Jones added an RBI single off lefty Javier Lopez and made a leaping catch in the netting of the photographers' pit in foul territory in the bottom of the ninth. Mike Dunn (4-3) pitched a scoreless eighth, and Steve Cishek converted his eighth save for Miami.
Neither starter pitched well but did just enough to give his team a chance in the final innings.
Henderson Alvarez allowed five runs - four earned - and 10 hits in six innings for the Marlins. He struck out four and walked none.
Giants right-hander Yusmeiro Petit, filling in while Tim Hudson rested his nagging hip, gave up five runs - four earned - on seven hits in five innings. He struck out five and walked none.
''I lost a little bit of my command in the first inning. I tried to stay close in the game,'' Petit said.
After wasting a 4-1 lead in a loss Thursday night to San Francisco, Miami moved ahead 4-1 again but rallied back late this time.
The Giants had three RBI hits with two outs, including pinch-hitter Gregor Blanco's bloop single in the sixth that tied it at 5-all. Blanco's hit came after McGehee couldn't corral a grounder at third.
''I still feel terrible. Alvarez battled through and it would've been nice to get him the win,'' McGehee said.
Defense - or a lack thereof - proved pivotal in the late innings.
Redmond successfully challenged a transfer rule call in the fifth. After a replay review, umpires ruled Marlins right fielder Giancarlo Stanton caught Hunter Pence's fly in the web of his glove and dropped the ball trying to transfer it to his hand for a throw.
Buster Posey's flyout to right later scored Angel Pagan, who had advanced to third on Stanton's botched transfer. Stanton made up for the play with an outstretched catch of Michael Morse's fly near the wall in the eighth.
Pagan also made a spectacular over-the-head catch on Dietrich's deep fly for the first out of the seventh and held on after running into the padded wall in left-center. And Casilla got pinch-hitter Ed Lucas to ground into a double play with the bases loaded to end the eighth.
NOTES: It was the fifth time Saltalamacchia had four hits in a game. ... Stanton's career-high 17-game hitting streak ended after going 0 for 5. ... San Francisco hosted ''Metallica Night,'' which included members of the heavy metal band playing the national anthem, drummer Lars Ulrich throwing out the ceremonial first pitch and singer James Hetfield announcing San Francisco's starting lineup. ... RHP Tim Lincecum (3-2 4.78 ERA) starts for the Giants opposite Miami's RHP Tom Koehler (3-3, 2.57) on Saturday.