Tracy McGrady is heading to the New York Knicks, who now have more than $9 million of additional salary-cap space to use in free agency this summer.
The Houston Rockets, Sacramento Kings and New York Knicks have agreed to terms that expanded the Houston-Sacramento deal into a three-way trade.
The Knicks acquired McGrady and Sergio Rodriguez from Sacramento; the Rockets get Kevin Martin and Hilton Armstrong from Sacramento, and Jordan Hill and Jared Jeffries from New York.
"This deal is about putting a team together, players who can help us now and in the future," general manager Daryl Morey said. "We're excited about how this sets us up for now and especially in the next year."
Houston also has the right to swap first-round picks with New York in 2011, and the Rockets also get New York's 2012 first-round pick.
Sacramento obtains Houston's Carl Landry and Joey Dorsey and New York's Larry Hughes.
A source close to the negotiations told ESPN NBA Insider Chad Ford that the Knicks' 2011 pick is top-1 protected, and the 2012 pick is top-5 protected.
The deal puts the Knicks more than $30 million below the salary cap on July 1, when they will pursue several members of a free-agent class headed by LeBron James, Chris Bosh and Dwyane Wade.
Depending on where the 2010-11 salary cap is set, the Knicks could have enough room to make maximum offers to two free agents, which was the lofty goal team president Donnie Walsh set for himself upon taking over nearly two years ago. The Knicks have not been below the salary cap since 1996, when they signed free agents Allan Houston and Chris Childs.
The Rockets and Kings agreed on a McGrady trade late Wednesday night, and the Knicks -- who had been in detailed discussions with the Rockets for weeks -- came in as the third team with basically the same package they were originally offering to Houston.
McGrady's nearly $23 million salary comes off the books July 1, as does Al Harrington's $10 million contract and Chris Duhon's $6 million deal.
"I have tremendous respect for [owner] Leslie Alexander and have enjoyed playing for the Rockets over the last six years," McGrady wrote. "It has definitely been the most profound part of my career. I've learned a lot about myself from various situations, both good and bad that have occurred here. It was my hope when I came to Houston that I wouldn't leave, but I do understand this is the business side of basketball."
The Knicks also reached agreement Thursday on a trade sending Nate Robinson and a second player to Boston for Eddie House, Bill Walker and J.R. Giddens.
Senior writer Marc Stein and ESPN Insider's Chris Sheridan cover the NBA for ESPN.com. Information from the Associated Press was used in this report.