Paul Maholm (9-8) pitched into the ninth inning for last-place Pittsburgh, which snapped a six-game losing streak and won for the fourth time in 21 games.
Rookie Luis Cruz also had three hits for the Pirates, who finished with 14 hits.
McLouth finished a single short of the cycle, hitting a two-run home run in the third, a three-run double in the fifth and a triple in the sixth. The center fielder, who scored three runs, also walked in the first and reached base on an error in the eighth.
Pittsburgh improved to 8-7 against St. Louis, getting its most wins in a season against the Cardinals since 1997.
Mark Johnson drove in a run for St. Louis, which lost its third straight to fall five games behind Milwaukee in the National League wild-card race. The Brewers were rained out at Philadelphia.
Pittsburgh sent 11 batters to the plate during a six-run fifth inning that chased St. Louis starter Joel Pineiro (6-6). Pineiro, who was making his first start since September 1, allowed seven runs and eight hits in four-plus innings.
Maholm allowed the first four hitters to reach base before being removed in the ninth inning. He allowed two runs and seven hits. The left-hander, who came in hitting .103 with one RBI, also had two hits and two RBIs.
The start of the game was delayed 1 hour, 13 minutes by rain.
Notes:@ RHP Daniel McCutchen, acquired from the New York Yankees as part of the Xavier Nady trade, joined the Pirates for their series against the Cardinals, though he wasn't activated. McCutchen said the move was made for him to "hang out and see what it's like in the big leagues." Pittsburgh plans to do the same with former first-round picks Neil Walker and Andrew McCutchen during their 10-game homestand. ... The inclement weather forced the Pirates to postpone afternoon activities planned outside PNC Park in honor of Roberto Clemente Day. They were rescheduled for next Friday before the Pirates play Houston. ... Brian Barden, who was called up by St. Louis on September 2, made his first start of the season at second base. ... St. Louis RHP Brad Thompson originally was scheduled to start Friday, with Pineiro set to pitch Sunday. Cardinals manager Tony La Russa decided to switch the two late Thursday night.