Last-place Pittsburgh lost its eighth straight despite a six-run fifth that briefly gave it the lead after trailing 5-0 -- only to watch Albert Pujols give St. Louis the lead again the following half-inning with a three-run homer, his major league-leading 43rd.
"He had that one bad inning," Ludwick said of Wainwright. "He's been so dominating as of late, to be able to come back and get him out of it -- being that he really hasn't done that at all of late -- it was nice. It was nice to be able to help him out, get him off the hook and get this first win of the series."
Matt Holliday also homered and Mark DeRosa added three hits for St. Louis, which has won six of seven and 17 of 21 to extend its lead in the National League Central to 11 1/2 games over the Chicago Cubs.
"[Wainwright] is having a great, great year, nobody's getting anything off him and all of a sudden, there's the one big inning," Cardinals manager Tony La Russa said. "He just looked like he ran out of gas ... But I liked it because sometimes he picks us up. It's a good team thing."
Ludwick and Holliday hit back-to-back solo home runs off of Kevin Hart in the third extend the Cardinals' lead to 4-0, and Ludwick also hit a three-run shot in the eighth for his eighth career multihomer game, third this season.
NL Cy Young candidate Wainwright (17-7) cruised through the first four innings, allowing only four baserunners and holding a 5-0 lead until, with one out in the fifth, seven of eight Pirates batters reached to give them a 6-5 lead.
The six earned runs Wainwright allowed in that inning were as many as he allowed in both of the entire months of July and August -- when he made six starts each month, going 4-1 each time.
"I didn't execute my pitches that inning is really all it comes down to," Wainwright said. "And the team is my saving grace. Right now if it wasn't for my team scoring eight runs for me, I would be hard to talk to."
Wainwright was in line to receive a loss for only the second time in nine starts when left the game after five innings having been charged with six runs on nine hits and two walks, striking out five.
But Pujols' homer -- a line drive that cleared the left-field wall quickly -- was only the beginning of a nine-run Cardinals' outburst over the course of three innings to put away the game.
St. Louis has scored only four combined runs in Wainwright's past three losses.
"I think it was about time we picked our pitchers up," Pujols said. "Obviously, they've been pitching so great over the last six weeks and we haven't scored enough runs. But today we came back after he gave up six to help him out to get a win. Obviously, he deserves it. He's been pitching so well, and we haven't scored a lot of runs for him."
Hart (4-5) was charged with seven runs -- five earned -- on nine hits and three walks with three strikeouts in 5 2/3 innings. He fell to 1-4 with a 6.35 ERA in six starts with Pittsburgh since being acquired in a trade from the Chicago Cubs on July 30.
"It's one of those things where when we score six in the bottom of the inning, you've got to go out there and have a shutdown inning," Hart said. "These guys picked me up tonight, and I didn't do the same."
Ryan Doumit went 3 for 5, Lastings Milledge went 2 for 3 with a walk and Andy LaRoche and Brandon Moss each had two RBIs for the Pirates (53-80), who are two losses away from establishing the record for consecutive losing seasons by a North American professional sports team with their 17th.
"They didn't lay over and play dead; that's encouraging," Pirates manager John Russell said of his team. "But it's tough to win games when you give up 14 runs."
Ludwick, who has 86 RBIs in only 115 games this season, had four previous four-hit games but had two doubles and a single besides his home runs.
"That's the kind of night you have in Little League; you don't have those in the major leagues," La Russa said. "And they were all clutch."
Wainwright had made 26 consecutive starts in which he lasted at least six innings. He hadn't allowed more than two runs in any of his past 12 outings. ... The Cardinals have won 14 of Wainwright's past 18 starts, including the last six. ... Despite the Pirates' losing streak, they had actually won seven of their previous nine home games. ... Holliday's homer was his 11th in 38 games with St. Louis -- as many as he hit with Oakland before a July 24 trade. ... Ludwick now has 20 home runs.