Pedro Alvarez went 4-for-5 with two home runs and four RBI and James McDonald silenced the Cardinals to get the Pirates back on track with a 9-0 victory in the middle test of a three-game series.
Alvarez's huge game was highlighted by the longest home run hit by a Pirates player at PNC Park, a solo shot in the sixth inning that traveled an estimated 469 feet.
McDonald (12-6) allowed just two hits and one walk while striking out six over seven scoreless innings for Pittsburgh, which had lost six of seven coming in.
Jake Westbrook (13-10) fell to 1-7 lifetime against the Pirates after getting touched for seven runs on 11 hits and four walks in five innings.
The Cardinals still hold the second wild-card spot in the National League, a position the Pirates trail by two games.
St. Louis played most of the game without All-Star catcher Yadier Molina, who exited after a home-plate collision with Josh Harrison in the second inning.
Harrison was trying to score from second on Jose Tabata's base hit, and Molina caught Carlos Beltran's throw from right while turning towards the runner.
Harrison lowered his left shoulder and struck Molina in the helmet as both players fell to the ground. Molina held on for the final out, but the All-Star backstop struggled making it to his feet.
"My back, my neck and my shoulder are a little sore," Molina said after the game. "Hopefully with treatment I'll get better."
Molina was replaced by Tony Cruz in the bottom of the third, the same inning Alvarez made it 3-0 with a two-run shot to left-center. Tabata had scored in the first inning on Garrett Jones' sacrifice fly.
Pittsburgh pushed four more across in the fifth, which began with four straight hits. Alvarez doubled in Andrew McCutchen and Michael McKenry's base hit scored Jones for a 5-0 cushion.
Westbrook then plunked Harrison on the leg to load the bases, and Clint Barmes followed with a two-run single through the left side.
Alvarez recorded his fifth career multi-homer game in the sixth when he abused a Brandon Dickson offering. The towering shot cleared the stands in center field and bounced along the sidewalk just in front of the Allegheny River, giving an unsuspecting fan a rare souvenir.
"He can shrink a ballpark," Pirates manager Clint Hurdle said of Alvarez. "He has raw power."
Travis Snider's RBI triple in the seventh accounted for the final run.
Chris Resop pitched the eighth and Hisanori Takahashi finished off the shutout with a 1-2-3 ninth.
Before the game, Pittsburgh released starting pitcher Erik Bedard ... The Pirates had 14 hits, five in 12 chances with runners in scoring position ... Jon Jay's double in the sixth served as the Cardinals' only extra-base hit ... St. Louis second baseman David Freese returned from a three-game absence (wrist) and went 1-for-3 ... The rubber match on Wednesday, which is also the last time these NL Central foes play this season, will pit Pittsburgh's Wandy Rodriguez against Joe Kelly.