J.T. Realmuto and Jeff Baker also went deep as Miami dinged a struggling Jonathon Niese, who lasted only four innings. The Marlins had lost 14 of 17 before taking the first two games of this series, giving them four straight wins against the NL East rival Mets after dropping the first five meetings this season.
Six relievers combined for 5 2/3 shutout innings of two-hit ball, and Miami won consecutive road games for the first time since April 22-23.
Stanton launched his 15th homer in the ninth an estimated 455 feet deep into the second deck in left-center. Baker connected on the next pitch from Alex Torres, giving the Marlins back-to-back homers for the first time this year.
It was Stanton's 15th career two-homer game.