Adam Wainwright worked seven effective innings to help St. Louis beat Pittsburgh 5-1 on Thursday to avoid a four-game sweep and end the Pirates' season-best seven-game winning streak.
Wainwright matched his season best with nine strikeouts and got his 129th career win, passing Harry Brecheen for seventh on the franchise list. He's permitted one run over 14 innings his last two outings.
Stephen Piscotty hit a three-run home run and Randal Grichuk also went deep for St. Louis, which reclaimed second place in the NL Central by a half-game over Pittsburgh to end a rough 4-5 homestand.
Jordy Mercer doubled and had an RBI for the Pirates, who had come from behind to win the previous six games.
Aledmys Diaz tripled off the top of the left-field fence and scored on a wild pitch to tie it in the fourth. Grichuk's first homer since June 12 gave the Cardinals the lead for good in the fifth.
All-Star Matt Carpenter (oblique) joined Brandon Moss (ankle) and Brayan Pena (knee) on the 15-day disabled list earlier in the day.
Diaz was named an All-Star earlier in the day to replace Carpenter.
Michael Wacha (5-7, 4.38) has won three straight starts and faces the Brewers for the second straight time.