MIAMI (AP) -- Yadier Molina went more than two months without a home run. He picked a good time to end the drought.
Joe Mather added a pinch-hit home run in the ninth for the Cardinals, who took the opener of a four-game series to stay within three games of NL wild-card leader Milwaukee.
Molina gave St. Louis a 3-2 lead in the fourth with his fifth homer of the season and first since June 10 at Boston.
"I just went up there wanting to put the ball in play," Molina said. "I made good contact and the ball just took off. You don't go up there looking for home runs, but when they help the team win it's a good feeling."
Molina also threw out Dan Uggla twice trying to steal second, including with nobody out in the ninth.
"Our catcher was the difference tonight," Cardinals manager Tony La Russa said. "In a hard, close game like that one guy can mean winning or losing. We don't win tonight without his effort."
The low-budget Marlins, who began the day 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 tough jam in the eighth to protect a one-run lead, and Chris Perez pitched the ninth for his second save.
"My sinker was working and I kept the ball low," Pineiro said. "Those were really the keys. Then you just rely on the guys behind you. We got a couple of key double plays and our bullpen did a great job."
Anibal Sanchez (1-2), making his third start since returning from shoulder surgery, tossed seven innings. He allowed three runs and six hits while striking out eight, equaling his career high.
"I think I had a good game but the other pitcher threw a good game for them, too," Sanchez said. "Today I felt this was my best start since I've been back. I felt good. I just threw a lot of fastballs."
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.
"Sometimes you get him in and sometimes you don't," Willingham said. "[Sanchez] definitely did his job. He kept us in the game. We just didn't help him out very much."
Mather's two-out homer to left off Joe Nelson in the ninth made the score 4-2.
Molina's shot over the left-field scoreboard scored Ankiel, who was hit by a pitch leading off the fourth.
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 Molina's throwing error. Ramirez scored on a wild pitch by Pineiro that bounced into the stands.
It was Mather's second pinch-hit homer of the year. ... Ankiel returned to the starting lineup after missing 14 starts with an abdominal strain. ... It was Pineiro's first career start against the Marlins in 246 games, most of them in the American League. ... Florida 3B Jorge Cantu was rested. He has missed only four games this season.