Lynn (5-4), who had been sidelined with a strained forearm, allowed only two hits and lowered his ERA to 2.84.
Backup infielder Pete Kozma, who came into the game hitless in his past 21 at-bats, singled three times, scored twice and drove in a run for his second RBI this year. His average rose to from .093 to .140.
The sweep was the first for the Cardinals in Miami since Aug. 4-7, 2011. St. Louis (48-24) moved a season-high 24 games above .500, while Miami (30-44) fell a season-worst 14 games under .500.
Miami’s Adeiny Hechavarria homered with two outs in the ninth to avert a shutout.
Dan Haren (6-5) allowed four runs in six-plus innings.