Lynn (11-3) broke a personal two-start losing streak, yielding seven hits. The right-hander issued just one walk and struck out seven on his way to the victory.
Trevor Rosenthal hurled scoreless eighth inning and Edward Mujica provided a 1-2-3 ninth for his 23rd save as the Cards won for the fourth time in six games overall.
Matt Holliday belted a solo homer and Carlos Beltran stole home in the third inning for second-place St. Louis, which came into the game trailing National League Central-leading Pittsburgh by one game.
Miami's Jose Fernandez (5-5) was saddled with the loss after allowing three runs on four hits over six full innings.
Adeiny Hechavarria and Jeff Mathis each drove in a run for the Marlins.