Fernandez (7-5) notched a 10th straight start of allowing three earned runs or fewer, limiting the Pirates to a pair of runs on five hits. The rookie right-hander didn't issue walk in the 97-pitch performance.
Steve Cishek survived a shaky ninth to record his 22nd save as the Marlins took the rubber match of a three-game series.
Miami trailed 2-0 in the fourth inning but collected RBI from Ed Lucas and Donovan Solano to tie the score before Stanton connected for his decisive solo shot in the sixth.
Gerrit Cole (5-4) absorbed the loss, surrendering three runs on four hits over seven frames. He walked two and fanned eight.
Russell Martin went 2-for-3 with an RBI for Pittsburgh, which came into the contest trailing first-place St. Louis by 1 1/2 games in the National League Central Division.
UPI horse racing roundup