ST. LOUIS (AP) -- Neifi Perez took a big swing and hoped for the best.
"I hit the ball thinking it was going to go foul," he said. "Thank God it didn't."
Perez hit his second career grand slam in the 10th inning, after the Cubs blew a one-run lead with two outs in the ninth, and Chicago beat the St. Louis Cardinals 8-4 on Sunday night.
Mark Prior gave up three home runs in the first and closer Ryan Dempster blew the save, but still the Cubs took two of three from the NL's best team because Perez's drive down the right field line landed just inside the foul pole.
"I was just hoping that ball was going to stay fair and the ball went out and disappeared," manager Dusty Baker said. "That was the most beautiful disappearing act I've seen in a long time."
Aramis Ramirez's 27th homer in the eighth, a two-run shot off Julian Tavarez, had given the Cubs a 4-3 lead as the St. Louis bullpen failed to hold a one-run lead for Jeff Suppan for the second straight start.
Todd Walker started the winning rally with a double off Al Reyes
(3-2). Derrek Lee and Ramirez were intentionally walked around a sacrifice by Jeromy Burnitz to load the bases, and with two outs Perez lined Reyes' first pitch to right for his eighth homer and first grand slam since July 3, 1999, against the Padres.
Reyes was just trying to get ahead in the count. He has extra time to dwell on it since the Cardinals are off on Monday.
"I was trying to make a good pitch in a good location, so I missed the location, and he took advantage," Reyes said. "Tomorrow is going to be good day to forget what happened tonight."
The Cardinals jumped on Prior for three solo home runs in the first inning and then managed only four hits the rest of the way and concluded a 6-4 homestand.
"We lost a couple of games in this homestand like that," St. Louis manager Tony La Russa said. "You leave it open for the other club and they're liable to get you, no matter how good your bullpen is."
Henry Blanco had his second career four-hit game and drove in two runs for the Cubs, who are 7-4 since the All-Star break. Blanco, the Cubs' backup catcher, entered the game batting .176 with eight RBI.
Lee was 0-for-1 with four walks for the Cubs, ending a seven-game hitting streak during which he was 11-for-31 with five homers and nine RBI. One of the walks came with one out in the seventh against Brad Thompson, and he scored with two outs when Ramirez hit a 1-1 pitch from Tavarez over the left-field wall for his 27th home run.
Ramirez is 16-for-35 (.457) during an eight-game hitting streak. He was 14-for-30 on the Cubs' seven-game trip with six homers and 11 RBI and helped the Cubs raise their record in St. Louis the last six seasons to 11-33.
In six innings, Suppan was troubled only by Blanco and allowed two runs on five hits.
"He pitched well enough to win," La Russa said. "We got three and couldn't add any more. You've got to add."
Three of the Cardinals' first five batters took Prior over the right field wall as Abraham Nunez connected with one out and Jim Edmonds and John Mabry followed with back-to-back two-out shots. Prior allowed only an infield hit in his last five innings.
It was the first time the Cardinals hit three homers in an inning since April 9, 2004, at Arizona. It was also the first time in Prior's career that he allowed back-to-back homers and the first time he'd surrendered three in an inning.
Entering the game, Prior had given up 11 homers in 88 2/3 innings. ... Lee is 9-for-18 against Suppan. ... Cardinals rookie John Rodriguez struck out as a pinch-hitter in the sixth after just missing on a homer earlier in the count, ending his hitting streak at six games. He did not start after spraining his right ankle tripping over an exposed nail in the dugout steps on Sunday. .... Paid attendance of 49,762 gave the Cardinals a sold-out series against the Cubs and their 23rd sellout of the year. ... Tavarez also blew the lead for Suppan on Tuesday, surrendering a two-run, eighth-inning double to the Brewers' Bill Hall. ... Dempster blew his second save in 16 attempts.