CINCINNATI (AP) Tommy Pham hit a tiebreaking, two-run homer in the sixth inning, pinch-hitter Matt Adams added a two-run drive in a five-run eighth and the St. Louis Cardinals rallied to beat the Cincinnati Reds 9-2 Sunday and avoid getting swept in the four-game series.

The Cardinals, on their worst stretch this season, had lost eight of 10 going into the series finale, and their division lead over Pittsburgh was down to 2 1/2 games. St. Louis then fell behind 2-0 on Todd Frazier's second-inning homer and Tucker Barnhart's fourth-inning sacrifice fly.

Those were the only runs the Reds would score against Michael Wacha (16-5), who allowed three hits and four walks in six innings.

More from FoxSports

Outscored 20-3 in the first three games, the Cardinals tied the score in the fifth against Raisel Iglesias on Kolten Wong's run-scoring infield single and Matt Carpenter's RBI single.

Sam LeCure (0-1) walked Greg Garcia and Pham homered on a 2-2 pitch for a 4-2 lead, his second home run of the season and first since July 5.

St. Louis broke open the game in the eighth against Carlos Contreras, when Barnhart's passed ball allowed Wong to come home from third, and Jason Heyward hit an RBI double and scored on Yadier Molina's single.

Adams, was activated from the disabled list on Wednesday after missing 91 games with a right quadriceps injury, homered for the first time since May 20.

Jason Heyward, who watched Adam Duvall's go-ahead, two-run homer bounce off the top of the wall in Saturday's completion of a suspended game, made a leaping catch in right to rob Ivan De Jesus Jr. of what would have been a go-ahead home run in the fifth.

TRAINER'S ROOM

Cardinals: Manager Mike Matheny wouldn't commit to RHP Adam Wainwright (Achilles tendon) or OF Matt Holliday (quadriceps strain) returning for the series in Milwaukee that starts Tuesday.

Reds: RF Jay Bruce and 2B Brandon Phillips both got Sunday off.

UP NEXT

Cardinals: After an off day, RHP Carlos Martinez (13-7) starts at the Brewers.

Reds: RHP Keyvius Sampson (2-4) is Cincinnati's scheduled starter in Monday's opener of a three-game series in San Francisco.