The Astros dealt Oswalt and cash to the two-time NL champions for pitcher J.A. Happ and two speedy prospects, outfielder Anthony Gose and shortstop Jonathan Villar.
Oswalt joins a rotation headed by star Roy Halladay, acquired from Toronto in the offseason.
CBSSports.com Analysis: Oswalt Going to Phillies
This was the second straight year the Phillies made a major trade for a pitcher in the days leading up to the July 31 deadline. Last season, they got Cliff Lee and he boosted them into the World Series Lee was then sent to Seattle as part of the three-team trade that brought Halladay to Philadelphia.
The Phillies took a seven-game winning streak into Thursday night's game against Arizona. Philadelphia began the day 3½ games behind Atlanta in the NL East.
St. Louis also had been bargaining for Oswalt. He had a no-trade clause in his contract and could decide whether to accept any deal.
The 32-year-old Oswalt was 6-12 despite a 3.24 ERA for Houston. The Astros were shut out in five of his 20 starts.
The righty helped the Astros get to the 2005 World Series, but they are far out of playoff contention this year. Oswalt is 4-0 in the postseason.
Oswalt is 143-82 with a 3.24 ERA in 10 seasons with the Astros. He is due about $5.33 million the rest of this season from his $15 million salary and is owed $16 million in 2011. Oswalt's contract has a $16 million club option for 2012 with a $2 million buyout.
The Astros seemed set to send about $11 million to the Phillies as part of the deal.
Happ has made one start after missing three months with an elbow injury. The 27-year-old lefty went 12-4 with a 2.93 ERA and finished runner-up for the NL Rookie of the Year award last season.
The 19-year-old Gose is speedy, stealing 36 bases and hitting .263 for advanced Class A Clearwater.
Villar, also 19, stole 38 bases and batted .272 for Class A Lakewood.