Save for that one last crack at tying the Astros’ all-time record for wins, Roy Oswalt got what he wanted.

Some two months after he asked to be dealt to a contender, the Astros on Thursday parted ways with one of the greatest pitchers in franchise history, sending Oswalt to the Philadelphia Phillies after he agreed to waive his no-trade clause.

“It’s tough to leave Houston,” Oswalt said. “But I’m going to a good situation.”

Still, the reality — not to mention the magnitude — of what had just transpired hit him when he stepped into the Minute Maid Park clubhouse, his baseball home for the past 10 years, to pack his belongings.

“I’m gone,” said Oswalt, who has been tied to the Astros for 14 years. “It’s pretty tough packing up my locker.”

In return, the Astros landed lefthander J.A. Happ, who will start tonight’s game against Milwaukee, and prospects Jonathan Villar and Anthony Gose. They then traded Gose to Toronto for promising minor league first baseman Brett Wallace.

James Nielsen/Chronicle

“We’re very appreciative of what Roy Oswalt has done for the organization,” Astros general manager Ed Wade said in announcing the trade.

The deal didn’t come cheaply for the Astros, who agreed to absorb some $11 million of the roughly $22 million owed to Oswalt through 2011.

The trade came one day before Oswalt, 32, was to start against the Brewers. He leaves the Astros a win short of tying Joe Niekro’s club record of 144.

Oswalt had been in pursuit of the record against the backdrop of the July 31 trading deadline. Last month, and partly at his request, Oswalt was moved back in the rotation to foster two starts at home before the end of the month. The last one was not to be.

Quickly starts new job

Instead, he will debut as the Phillies’ starter tonight at Washington.

“Roy wanted to go to a team that has a chance to be in the playoffs and a chance to win a World Series, not only this year but for the next few years,” said Bob Garber, Oswalt’s agent. “Philadelphia presented the best option.”

Oswalt’s hefty contract — he is owed about $5.5 million for the remainder of this season and $16 million in 2011 — made him tough to trade. He was the top pitcher on the market yet hardly the most coveted because of it.

But with the clock ticking, the Astros willing to take on $11 million of Oswalt’s salary, and the pitcher softening his stance on having a $16 million option for 2012 picked up, the Phillies decided to make a move.

“At first we didn’t think it would go to that magnitude,” Astros owner Drayton McLane said of the amount of salary absorbed. “But that’s the way the market is now.”

Discouraged by his team’s abysmal start this season, Oswalt in May asked the Astros to consider trading him to a contender, citing his desire to play for a team that would give him a chance to return to the World Series. The Phillies have made back-to-back trips to the Fall Classic — winning in 2008 and falling to the New York Yankees last year — and are a solid threat to get there again. They have won eight straight games and surged within 2½ games of Atlanta in the NL East, making up 4½ games in the last week.

From the beginning, Oswalt suggested a trade could be in the Astros’ best interest, allowing them to replenish a depleted farm system. In acquiring Happ, the Astros landed a promising lefthander who was runner-up for National League Rookie of the Year honors in 2009. Villar, 19, is a shortstop, and Wallace, 23, is a first baseman regarded as a hitting machine.

To make the deal happen, Oswalt dropped his request that the Phillies guarantee the 2012 option, Garber said.

With Saturday’s 3 p.m. MLB non-waiver trade deadline fast approaching, the Phillies were the only trade option presented to Oswalt by the Astros. Philadelphia beat out the St. Louis Cardinals, Los Angeles Dodgers and Texas Rangers in their pursuit of Oswalt, who had a no-trade clause. Garber said Oswalt also learned of interest on the part of the San Diego Padres earlier in the week.

Oswalt was presented with the trade proposal Wednesday. The Phillies gave him until midday Thursday to decide on it.

A 23rd-round pick by the Astros in the 1996 amateur draft, Oswalt leaves an indelible mark in Astros history. His .636 winning percentage (minimum 140 decisions) ranks tops in club history, and his 3.24 ERA is top-five in franchise annals.

Two 20-win seasons

A three-time All-Star and two-time 20-game winner, Oswalt also is third in starts (291) behind Larry Dierker and Niekro and was a key part of the 2005 Astros team that made the franchise’s lone World Series appearance.

“He’s a guy that did what the organization asked of him,” longtime teammate Lance Berkman said. “He gives you a chance to win every time out.”

Since debuting in 2001, Oswalt ranks third among active pitchers in ERA and wins, trailing only CC Sabathia and Roy Halladay in the latter category.

Bad record, good ERA

Oswalt (143-82, 3.24 ERA) leaves after posting a 6-12 record and 3.42 ERA through 20 starts this season.

Hitting coach Jeff Bagwell, who played five seasons with Oswalt, remembers seeing something special in him.

“When he came up, Roy was a big strikeout pitcher,” Bagwell said. “He struck out a bunch of guys and did it very efficiently.

“Once Roy came up and we had Wade Miller and Carlos Hernandez, I said, ‘We’re going to be good for a long time.’ Those two guys got hurt, but Roy has had a tremendous career.

“Unfortunately, it doesn’t look like it’s going to end with us. But it’s been a pleasure.”

The Chronicle’s Jose de Jesus Oritz contributed to this report.