HOUSTON -- Don't count the defending NL champions out of the playoff picture just yet.
The Astros remained 5½ games back in the wild-card race. They've won three of their last four and after the game, manager Phil Garner said Roger Clemens will start the regular-season home finale against St. Louis on Sunday.
"I guess we can pull out all the stops now," Berkman said.
The switch-hitting first baseman tied a career high with his 42nd homer in the fifth, then set a new mark with a go-ahead two-run drive into the Astros' bullpen in the eighth.
"These games are fun," Berkman said. "If we can keep that glimmer of hope alive, you love to play in games like this."
St. Louis manager Tony La Russa admitted he erred by not ordering Carpenter to walk Berkman in the decisive at-bat.
"I kick myself for that eighth inning," La Russa said. "I blame myself for that. He (Carpenter) pitched well."
Carpenter (15-7) lost for the first time in nine starts. The Cardinals' magic number for clinching the NL Central remains at five.
"When you have one of the best pitchers in the game, and you score five runs, sometimes you say it's enough," St. Louis slugger Albert Pujols said. "Obviously, it wasn't."
Berkman's homers bailed out the sloppy Astros, who committed two errors and gave up four unearned runs.
Carpenter and former Astro Preston Wilson led off the third with line-drive singles off Pettitte. The Astros released Wilson in mid-August and the Cardinals signed him the next day.
Pettitte fielded a weak grounder by Scott Spiezio and threw to second baseman Craig Biggio trying to start a double play. But Biggio mishandled the throw and the ball skipped into center as Carpenter scored.
Pujols grounded to Biggio and the Astros got a double play this time, but Wilson came home for a 2-0 lead.
Pettitte was called for a balk after Ronnie Belliard's one-out double in the fourth. Pettitte threw to first, appealing to first base umpire Angel Hernandez that Belliard had missed the bag. The appeal was denied and Hernandez ruled that Pettitte had thrown over without first touching the rubber.
Pettitte then threw a wild pitch with a 3-2 count on Yadier Molina and Belliard scored.
Carpenter retired eight in a row after Mike Lamb 's single in the first inning. Lamb singled again with one out in the fourth.
Berkman followed with a towering shot off the brick facade in left field, his 37th homer this season batting left-handed.
"Obviously, Lance had a nice night," Carpenter said. "I made some mistakes and he hit them hard."
Lamb, Houston's third baseman, bobbled a grounder by Wilson for another error in the fifth. Spiezio singled before Pujols singled off the right-field wall to drive in Wilson.
Juan Encarnacion grounded out before Pettitte intentionally walked Scott Rolen. Belliard then hit a sharp grounder to Lamb, who tagged out Pujols but couldn't get Belliard at first. Spiezio scored for a 5-2 lead.
Chris Burke doubled and Adam Everett singled in the Astros' fifth to spark another rally. Brad Ausmus put down a sacrifice bunt before Orlando Palmiero, hitting for Pettitte, lined a two-run single to center.
Pettitte struck out two and walked four in five innings. He allowed only one earned run, on the wild pitch.
"It was a struggle," Pettitte said. "I walked a few guys, made a few errors and made it tougher than I should've. But to be able to come back and win this game, that was huge."
Pettitte was making his first start since Sept. 12 in St. Louis, when he left with a strained muscle in his elbow. He was scheduled to start on Tuesday, but got it pushed back so he could be with his father, who underwent a heart procedure.
"I felt rusty," he said. "I didn't feel really good, but I kind of expected that."
Pinch-hitter Morgan Ensberg led off the eighth with a single. Biggio bunted and Lamb struck out before Berkman crushed a 3-2 pitch over the fence in right-center.
"I knew there was a chance he'd throw the kitchen sink up there," Berkman said. "He threw a cutter that he was trying to come inside with and it stayed a little over the middle."
- Berkman recorded his sixth multihomer game of the season.
- The Astros' two errors boosted their NL-low total to 73.
- Biggio has 637 career doubles, three behind Honus Wagner for eighth on the career list.
- The Cardinals have lost six of their last seven road games.