PITTSBURGH -- For 20 years, the Pittsburgh Pirates couldn't win. Now, it seems they cannot lose.
Martin delivered his fourth game-ending hit at PNC Park this year for the NL Central leaders.
The Pirates swept the three-game series and improved to 70-44, the best record in the majors. Miami lost a 4-0 lead and fell for the fifth time in a row.
Pittsburgh has had 20 consecutive losing seasons, a major North American professional sports record.
"It's been so much fun," Pirates second baseman Neil Walker said. "It seems like it's somebody different every day that's been the hero."
Josh Harrison opened the 10th with a single off Steve Ames (0-1) and took second on Clint Barmes' sacrifice bunt. After Jose Tabata bounced out and Starling Marte was intentionally walked, Martin batted for Jared Hughes (2-2) and grounded a single down the left-field line.
"I like those situations," Martin said. "Some people would say they are pressure situations, but I don't look at it that way. There is a heightened focus for me when the game is on the line and I feel more relaxed because of it. I feel I perform better with the game on the line."
It was the Pirates' 28th comeback win.
"It's just our mindset," Pittsburgh manager Clint Hurdle said. "Offensively, we know we've got some work to do and areas to improve on, but we're long on guts. We keep playing to the end and grinding out at-bats. We've shown the resolve to play out some big opportunities."
Walker had three hits and two RBIs for Pittsburgh and Marte had two hits. McCutchen was scratched from the starting lineup because of discomfort in his right shoulder, but singled as a pinch-hitter in the seventh.
Marlins rookie Christian Yelich had three hits, including his first major league homer.
Fernandez gave up two runs and five hits for Miami while walking four and striking out five. He had a combined 27 strikeouts in his previous two starts.
"Honestly I was nervous really from about the second inning on because I knew he didn't have his great stuff and you could see he was really having to work hard out there to throw strikes and get ahead of hitters," Marlins manager Mike Redmond said.
"Not that they hit him hard -- because they didn't -- but you could just see he was having to throw a lot of pitches to finish guys and they did a good job of that, of kind of battling him," he said.
Cole allowed four runs on six hits with one walk and four strikeouts. He is winless in seven starts since winning the first four starts of his career.
Four Pirates relievers then combined for five scoreless innings.
"It's a real luxury to have the type of bullpen we have," Cole said. "I feel bad because I hung them out to dry but they did a great job."
The Pirates tied the score at 4 in the seventh on sacrifice flies by Walker and pinch-hitter Gaby Sanchez. They had drawn within 4-2 in the fifth on consecutive RBI singles by Walker and Pedro Alvarez.
Miami built a 4-0 lead by scoring twice in the first and fifth innings. Giancarlo Stanton drove in the game's first run with a double and scored on Placido Polanco's single, then Yelich hit a two-run homer in the fifth.
"You've had a few at bats now and you know you're waiting for it to come," Yelich said, "but it's one of those things that you can't force it and start pressing for it because if you do that it can take you out of your game and it snowballs on you real quick. It was nice to get that first one but it would have felt a little better if we could have come up with a W."
Pittsburgh leads the major leagues with 41 home wins and Miami's 17 are the fewest. ... Miami 2B Donovan Solano was not in the lineup for the first time since July 23 and rookie CF Jake Marisnick was also rested. ... Both teams open three-game road series on Friday night with Miami visiting Atlanta and Pittsburgh playing at Colorado. RHP Justin Turner (3-3, 2.68) will start for the Marlins against RHP Brandon Beachy (0-0, 9.00). Pittsburgh LHP Francisco Liriano (12-4, 2.04) will face LHP Jorge De La Rosa (10-6, 3.31).