The low-budget Marlins, who began the day 2 1/2 games behind first-place Philadelphia in the NL East, fell six games off the wild-card pace.
Pineiro (5-5) allowed two runs, one earned, and seven hits while striking out four and walking two. Kyle McClellan worked out of a big jam in the eighth to protect a one-run lead, and Chris Perez pitched the ninth for his second save.
Anibal Sanchez (1-2), making his third start since returning from shoulder surgery on July 31, tossed seven innings. He allowed three runs and six hits while striking out eight, equaling his career high.
Cody Ross homered for the Marlins, who blew a great chance to tie the game in the eighth.
With his team trailing 3-2, Hanley Ramirez led off with a single against McClellan. Ramirez went to second when left fielder Rick Ankiel bobbled the ball
- and continued to third on a poor throw by Ankiel, who hadn't played left since last season. Ankiel was charged with two errors on the play.
But McClellan got out of trouble. Jeremy Hermida grounded to shortstop, Josh Willingham struck out and Mike Jacobs flied out, stranding Ramirez at third.
Mather's two-out homer to left off Joe Nelson in the ninth made the score 4-2.
The two-run homer by Molina off Sanchez in the fourth gave St. Louis a 3-2 lead. The shot over the left-field scoreboard scored Ankiel, who was hit by a pitch leading off the inning.
A solo home run by Ross in the second put the Marlins ahead 2-1.
The Cardinals took a 1-0 lead in the first on Ankiel's infield single that scored Felipe Lopez from third.
The Marlins tied it in the bottom half. Ramirez led off with a single, stole second and went to third on a throwing error by catcher Molina. Ramirez scored on a wild pitch by Pineiro that bounced into the stands.