Ransom's home run came in the second inning and was his second of the year, while Upton, who also has two homers, capped a five-run fourth-inning rally.
Arizona's Patrick Corbin, just called up from Double-A Mobile, picked up the win in his major-league debut. He allowed three runs off eight hits and three walks while striking out six in 5 2/3 innings.
That was good enough, however, as the Diamondbacks got to Miami starter Mark Buehrle (1-4) for seven runs (four earned) and eight hits in five innings.
Ransom's home run came after a Paul Goldschmidt single in the second.
The Marlins scored five runs over three innings. Donnie Murphy hit a two-run home run -- his second -- in the fifth, Gaby Sanchez delivered a sacrifice fly in the sixth and Austin Kearns added a two-home run -- his second of the season -- in the seventh that got Miami within 7-5.
Arizona scored a pair of ninth-inning runs on just one hit, a walk, a hit batter, a fielder's choice for a run and a sacrifice fly off Miami reliever Heath Bell.
Celebrity Families of 2014 [PHOTOS]