Chris Volstad (4-2) pitched five innings for the win in his sixth major league start. He gave up five hits and three walks, overcoming a poor start after the first five Cardinals batters reached base to give St. Louis a 3-0 lead.
Volstad yielded only two hits and a walk in his final four innings.
Four Florida relievers combined for four shutout innings after a rain delay of 1 hour, 53 minutes in the bottom of the fifth. Kevin Gregg pitched a perfect ninth for his 26th save in 32 opportunities.
The Cardinals didn't get a runner past second base after the first inning.
Kyle Lohse (13-5) gave up four runs and six hits, losing for the third time in four decisions. He came out after the rain delay.
The Marlins evened the four-game series between surprising playoff contenders at a game apiece.
Ramirez gave Florida a 4-3 lead in the second inning when he hit a 2-0 pitch for his first home run in August. He came into the game with only two RBIs in the month.
Ramirez was at the plate with nobody on and one out in the fifth when the rain came.
After Volstad gave up three runs in the first, the Marlins cut into the lead in the bottom half on Mike Jacobs' two-out RBI double.
Skip Schumaker and Felipe Lopez opened the game with back-to-back singles. After Albert Pujols walked, Ryan Ludwick hit a three-run double to put the Cardinals up 3-0.