PHILADELPHIA (AP) -- Lance Berkman fell behind in the count, hoped for a pitch he could handle and made the most of an inside-out swing.
Andy Pettitte allowed two runs and seven hits in 6 1/3 innings for Houston. Dan Wheeler (2-5) retired the two batters he faced to earn the win. Brad Lidge pitched the ninth, allowing an unearned run, for his 30th save in 35 chances.
The Phillies dropped three games behind NL wild card-leading San
Diego. They are tied with the Marlins at 70-69 going into a
four-game series at Florida starting Thursday night.
Pinch-hitter Orlando Palmeiro singled to start the ninth against Ryan Madson (10-9). Brad Ausmus sacrificed pinch-runner Eric Bruntlett to second base, Mike Lamb was intentionally walked and Willy Taveras punched a single to right field to load the bases.
Madson fanned Craig Biggio for the second out, but Berkman lined a 1-2 pitch down the left-field line to score all three runners.
"I'm just trying to survive up there," Berkman said. "He throws a lot of plus pitches. It's hard to know what you're going to get."
Madson went with his third-best pitch, a curveball, to Berkman. Phillies manager Charlie Manuel said he would've preferred a fastball inside, but Madson defended his decision.
"I got two guys out on the curve the previous inning so I had confidence in it," he said.
Jimmy Rollins had an RBI single in the ninth for the Phillies but appeared to slow down running to second base and was thrown out trying for a double on a strong throw from Taveras for the second out.
"I was shocked he was out. It was a great throw," Manuel said.
The Astros, who finished one game ahead of the Phillies to win the wild-card berth last year and advanced to the World Series, entered the night five games behind the Padres in the wild-card chase.
"Absolutely a must-win for us," Astros manager Phil Garner said.
Phillies starter Randy Wolf, making his eighth start since returning from Tommy John surgery, allowed two runs and five hits in six innings.
The Phillies loaded the bases with no outs in the sixth but only scored one run to tie it at 2.
Shane Victorino singled to start the inning and Chase Utley walked. Ryan Howard, who leads the majors with 53 homers, followed with a bouncer back to the mound. Pettitte, perhaps distracted by the standing ovation the fans gave Howard during his entire at-bat, let the ball trickle through his legs for an error.
Pettitte pitched out of a bases-loaded, one-out jam in the second by getting Abraham Nunez to ground into a double play.
"We didn't hit when we needed to and we didn't play smart baseball," Manuel said.
Ruiz, starting because Mike Lieberthal is out of the lineup with back spasms, homered to left leading off the bottom of the fifth to cut the deficit to 2-1.
The Astros took a 1-0 lead on Berkman's RBI double in the first inning. Chris Burke hit a one-out double in the fourth and scored on a single to left by Ausmus.
The Phillies, who play the next 10 games on the road, are 36-38 at home and 34-31 away.
Phillies left-hander Arthur Rhodes, who hasn't pitched since he blew his second straight save on Saturday, is day-to-day with shoulder
stiffness. ... The Astros improved to 51-25 when scoring first. ... Philadelphia's starters have a 2.50 ERA in the last eight games. ... Phillies left-handerP Matt Smith, one of four players acquired from the Yankees in the trade that sent Bobby Abreu to New York, struck out
the only batter he faced, Berkman. Smith hasn't allowed a run in 15
innings in the majors, including 12 innings with the Yankees. ... Utley, who hit a walk-off homer in the 10th inning to win Monday's game against Houston, has two hits in his last 27 at-bats with runners in scoring position.