Houston, TX – J.A. Happ was effective through six innings run homer, leading the 2, in the second meeting of a three-game series.
The Astros, owners of the worst record in the majors, beat the league's best for the second straight night and can earn an improbable sweep on Wednesday with Bud Norris going up against 17-game winner Roy Halladay.
Happ (6-15) followed up a stellar start by Brett Myers, also a former Phillie, with a quality outing, allowing just one run on four hits and four walks.
Hunter Pence homered in his second game as a visitor at Minute Maid Park, but Cole Hamels (14-8) lasted just five innings after getting touched for five runs -- four earned -- on nine hits in defeat, Philadelphia's third straight.
The NL East-leading Phillies still have a magic number of one to clinch a playoff spot and five to sew up the division.
"We got outplayed again," Phillies manager Charlie Manuel said. "We were taking things for granted. ... We're much better than that."
Barmes and J.D. Martinez hit back-to-back doubles in the first inning to stake Happ to a 1-0 lead.
Pence smacked a solo homer -- his ninth as a member of the Phillies -- in the fourth, but Houston pushed four across in the bottom half.
With one out and runners on the corners, Jason Bourgeois singled in J.B. Shuck before Barmes found the seats in left-center for his 11th home run of the season.
Happ popped up slugger Ryan Howard to leave the bases loaded in the fifth, Fernando Rodriguez was perfect in relief in the seventh and eighth frames, and David Carpenter shook off Carlos Ruiz's home run in the ninth to seal the win.
The Phils have lost just 12 of their 47 series thus far...Philadelphia came in a major league-best 30-9 in games against left-handed starters...Shuck went 3- for-3 as an injury replacement for Jason Michaels, who broke a finger on his left hand making a diving catch in the second inning...Game time: 2:33.