ST. LOUIS -- Pitching around Albert Pujols was crucial to Odalis Perez ending his struggles.
Perez intentionally walked Pujols to load the bases in the first and fifth and got out of each jam when cleanup hitter Juan Encarnacion grounded into inning-ending double plays.
"Those were the big ones," Perez said. "Pujols is the best guy in the lineup and if I hang any pitch he's going to hit it out and two or three runs are going to score.
"It was really good to put him on base and pitch to Encarnacion."
John Buck homered and Mark Teahen had two hits and an RBI for the Royals, starting a 10-game road trip after a season-best 6-3 homestand during which they took two of three from the Cardinals while outscoring them 28-16.
Wainwright (5-6) gave up five runs -- four earned -- in seven innings, five days after limiting the Royals to one hit in eight scoreless innings in Kansas City. He hurt himself considerably in the field, committing his first two errors of the season in the first and then making a mental error while trying for a spectacular play.
"What an idiot," Wainwright said. "My fielding stunk. What more can you say?"
Scott Rolen homered and So Taguchi had three hits for the Cardinals, 4-9 in interleague play. After the missed opportunities, Encarnacion singled in the eighth to extend his hitting streak to 18 games.
"It's part of the game," Encarnacion said. "So there's nothing I can say about it."
In six innings, Perez (4-7) allowed three runs and six hits -- a huge improvement after allowing an earned run per inning while going 1-3 in his previous four starts.
The left-hander is 2-5 in his last 10 starts, but ended a four-game losing streak against the Cardinals. Prior to Monday he had allowed five earned runs in 2 1/3 innings of relief at new Busch Stadium, which opened last year.
Pujols entered the game 13-for-19 with five homers and 15 RBI against Perez. Besides the intentional walks, Pujols struck out with a runner on third to end the third.
"He's only hitting like .700 against him," Royals manager Buddy Bell said. "We had no choice."
Octavio Dotel allowed a hit and struck out two in the ninth for his sixth save in six chances.
Wainwright threw wildly to first on a relatively easy play in the first, Esteban German's bunt just to the right of the mound, allowing German to go to second. A wild pickoff throw advanced German another base and he scored on Emil Brown's two-out hit to give the Royals a 1-0 lead.
The Royals scored twice in the fourth to take a 5-1 lead partly fueled by Wainwright's unsuccessful sliding attempt to glove Perez's popped-up bunt down the first-base line. Wainwright ended up sliding into foul territory along with the ball on what was ruled a single that put runners on first and second. Kansas City got a run-scoring groundout by German and Teahen's two-out RBI single.
Buck hit his 13th homer and David DeJesus added a run-scoring single in the second for Kansas City. Third baseman Alex Gordon made the defensive play of the game when he leaped to snare Taguchi's grounder in the third and made a strong throw just as he landed for the out on a close play.
"It doesn't get any better than that, just the instinct you have to have to understand the timing and knowing where you're at," said Bell, a former third baseman. "I haven't seen a play like that in a long time."
Taguchi's leadoff single in the first extended his hitting streak to 11 games. ... Buck has a career-best 13 homers after hitting 12 in 2004 and '05 and 11 in 2006. ... Rolen wasn't able to glove Brown's bouncer far to his left in the seventh, ending a 60-game errorless run for the 3B that dated to Sept. 27, 2006. ... Rolen's homer was his first since May 30 at Colorado. ... The Cardinals have been outscored 51-18 in the first inning.