John Buck singled to lead off the 11th, and pinch-runner Brett Hayes went to second on Chris Coghlan's sacrifice. After Jose Reyes was intentionally walked, both runners moved up on a wild pitch by David Carpenter (0-1).
Emilio Bonifacio was also walked to load the bases and Ramirez delivered a deep fly over the pulled-in outfield as the Marlins bounced back to take the rubber match of their three-game series.
Chad Gaudin (1-0) earned the victory after working out of jam in the top of the 11th.
Ramirez went 4-for-5 with a two-run homer -- the first for the Marlins in their new stadium.
Jose Altuve drove in a pair of runs for the Astros.
Reindeer recovered after escaping from Santa during lighting ceremony
Trader Joe's: Car crashes into Long Island store, injuring 11