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.
Pistorius testifies he didn't consciously pull trigger when he shot girlfriend
'Happy' fan videos make Pharrell cry [VIDEO]