Stanton's two-run shot in the sixth inning erased a 2-0 deficit and his solo blast in the ninth off Diamondbacks closer Heath Bell (2-1) gave Miami its first lead of the game.
Mike Dunn (2-1) collected the victory with a scoreless eighth and Steve Cishek got his 10th save with a 1-2-3 ninth as the Marlins claimed the opener of a three-game series.
Arizona starter Patrick Corbin got a no-decision after taming the Marlins on two runs on two hits over eight innings.
Paul Goldschmidt drove in both runs for the D-backs, who dropped a fourth straight.
Dennis Rodman pledges to end trips to North Korea
Senate Democrats to pull all-nighter on climate change