Lynn (12-5) had dropped four of his previous five decisions and was 3-4 with a 6.32 ERA in his past eight starts.
"I knew I had to be a lot better than I had been," Lynn said. "It was bad."
Lynn came out against the Phillies with an aggressive mindset, which paid immediate dividends. He realized quickly that he had rediscovered his early season groove.
"I had good stuff early on and I could feel it," Lynn said. "I knew I had it from the get-go. I was able to attack with my fastball and able to get into a rhythm."
Lynn, who was 8-1 with a 2.76 ERA in his first 12 starts, gave up just five hits against the slumping Phillies, who have scored just nine runs during the five-game skid. He struck out six and walked four.
Lynn's turnaround came at a perfect time. St. Louis is set to embark on an 11-game road swing beginning Friday in Atlanta.
Lynn, whose last win came on July 7, retired eight batters in a row from the fourth through seventh innings. He set the side down in order in the fifth and sixth on a combined 23 pitches.
"That's what we've been hoping to see," St. Louis manager Mike Matheny said. "He kept his focus and he still maintained his energy. He had impressive depth to his sinker."
Closer Edward Mujica picked up his 30th save in 32 opportunities. He struck out two and is tied with Pittsburgh's Jason Grilli for the most saves in the NL. Trevor Rosenthal pitched a scoreless eighth for the Cardinals.
Mujica, who converted his first 21 save opportunities this season, needed to 14 pitches to clinch the victory.
"At the beginning of the season, they gave me the ball in the seventh inning," Mujica said. "I never thought about being a closer. This is unbelievable for me."