The decisive run came in the sixth inning.
Coghlan singled and raced home from first after Hanley Ramirez singled, and the ball was misplayed in left field by Erik Komatsu.
Wasted chances hurt the Marlins until the fifth inning, but they were able to get back into the game courtesy of an unexpected source.
Daniel Pertusati, brought in from Minor League camp to help fill out the roster for one day, delivered a pinch-hit home run off Lance Lynn with two outs in the fifth.
Pertusati, 21, has 14 career homers in the Minors in 398 games.
The drive to left-center made it 1-1, and was the only run allowed by Lynn, who allowed five hits and struck out three in five innings.
Marlins starter Anibal Sanchez retired the first 10 Cardinals he faced, before St. Louis struck.
Carlos Beltran ended the string when he connected on a home run to right with one out in the fourth inning.
Lynn, the Cardinals' fifth starter, benefited by double-play ground balls in each of the first three innings. He threw 54 pitches, with 34 strikes.
"I was happy with it," Lynn said. "I was feeling much better and throwing the ball where I needed to to get ground balls. That one guy got me [with a home run] on a 3-2 pitch. You just tip your cap to that guy. He made a good swing, and I made a pitch for him to hit."
Miami's Brett Hayes added an RBI single off Scott Linebrink in the eighth.
Up next: Marlins ace and Opening Day starter Josh Johnson will make his final Grapefruit League appearance. The right-hander is lined up to throw about 90 pitches on Friday at 6:05 p.m. ET against the Nationals in Viera, live on MLB.TV. Washington is going with left-hander Ross Detwiler. Catcher John Buck, center fielder Emilio Bonifacio and second baseman Omar Infante are position players making the trip.