MIAMI -- The Miami Marlins hustled their way to an improbable victory on Tuesday, getting an odd but big home run from a rare source of power and hanging on when their closer had the night off.

Jarred Cosart pitched seven scoreless innings, and second baseman Donovan Solano slugged a two-run homer to lead Miami to a 3-0 win over the St. Louis Cardinals at Marlins Park.

The Marlins (59-60) will go for a three-game series sweep Wednesday.

St. Louis (62-56) lost for the fourth time in five games.

"I thought it was foul," Solano said of his second homer of the year, which went down the left-field line. "But I saw the ball come back to fair territory. That's when I started to run."

The homer was part of a three-run fourth against Cardinals ace Adam Wainwright (14-7), his only blemish in seven innings.

"Their eight-hole hitter decides to hit his second home run against the best pitcher in the league," Cardinals manager Mike Matheny said with disgust. "The ball went completely foul and then came back fair. I haven't seen that all year."

Miami's rally started when third baseman Casey McGehee led off with a hit that he stretched into a double when left fielder Matt Holliday seemed to retrieve the ball casually.

"Matt double-pumped, which gave (McGehee) the extra time because it was going to be a bang-bang play," Matheny said. "Sometimes a guy doesn't come up with the grip. You can't come up throwing if you don't have the right grip.

"Credit McGehee -- he wanted that. He made that happen on his first step out of the box. It ended up being the game-changing play."

After McGehee's double, first baseman Garrett Jones grounded out to second base. That might have been a double-play ball had it not been for McGehee's hustle. Instead, McGehee went to third and scored on a single by catcher Jarrod Saltalamacchia.

Then came Solano's two-out homer, with Cosart on deck.

Cosart (1-1), acquired from the Houston Astros late last month, earned his first win as a Marlin. But he went 0-for-2 at the plate with two strikeouts. He took only one swing because of an oblique injury that caused him to miss a turn in the rotation.

Matheny said he knew Cosart was hurt, but he did not feel the need to intentionally walk the light-hitting Solano in that situation. Besides, Matheny said, the Cards pitched the right-handed hitting Solano outside the strike zone ... and it still ended up as a homer.

Cosart, who did not have to swing the bat in the American League with the Astros, suffered the oblique injury while batting for the Marlins. And the last thing he wanted was a repeat.

"I don't want to embarrass myself and swing hard and hurt myself," he said. "I wanted to get through this game healthy, swing easy and work on getting in shape."

The right-hander allowed just three hits, all singles, and one walk while striking out three.

Cosart did not allow a runner past first base until the sixth, when he had to work around an error by Jones.

Marlins reliever A.J. Ramos worked a scoreless eighth inning, and Bryan Morris got the first two outs in the ninth before leaving behind a first-and-third jam.

Mike Dunn came on to clean up the mess, striking out pinch hitter Matt Adams for his first save of the season.

Miami closer Steve Cishek, who has 30 saves but had pitched four times in the past five days, got the night off.

The big hero, though, was Solano.

"His two homes this year are against Wainwright and David Price," Marlins manager Mike Redmond said. "You can book him for every ace in the league from here on out."

NOTES: The Cardinals rested 1B Matt Adams and started Mark Ellis, who went 2-for-3. Adams started 29 consecutive games and played tired Monday, going 0-for-5 with two strikeouts. ... Miami's Jordany Valdespin started in center field and went 1-for-3. He has made 15 starts this season at second, two in center field and one in right. ... The three-game series ends Wednesday when the Cardinals start RHP Justin Masterson against RHP Nathan Eovaldi. Masterson has allowed 10 runs in eight innings since the Cards acquired him from the Cleveland Indians. Eovaldi has allowed just one run in his past 15 innings covering two starts. The Marlins are 3-0 in his past three starts. ... Marlins RHP Henderson Alvarez (shoulder inflammation) is eligible to come off the disabled list Thursday but instead will start Saturday against Arizona.