The deal was first reported by ESPN The Magazine's Buster Olney.
The Pirates tried to work out an extension with Sanchez before the trade deadline, but after he rejected their overture, the Pirates traded him to the San Francisco Giants. Sanchez just signed a two-year, $12 million deal with San Francisco.
Iwamura will earn $4.85 million for 2010, through a club option negotiated in his original contract.
After Iwamura was hurt early in the 2009 season, Ben Zobrist developed into an excellent alternative for the Rays. By making this deal, Tampa Bay saves the $650,000 buyout on Iwamura's contract -- which they would have had to have paid if they had just rejected Iwamura's contract option -- and they get a serviceable and cheap young pitcher in Chavez, who won't be eligible for arbitration until after the 2011 season.
"We've got areas we really need to try to address," Rays executive vice president of baseball operations Andrew Friedman said, specifically mentioning the bullpen and catcher as priorities this offseason.
When the Pirates traded Sanchez, a three-time All-Star, he was leading the team in hitting. Delwyn Young stepped in at second and batted .266 with seven homers and 43 RBIs, but he struck out 90 times in 354 at-bats. The Pirates' top second base prospect, Chase d'Arnaud, isn't close to being ready for the majors.
Iwamura was batting over .300 early last season for the Rays before sustaining partial tears of the anterior cruciate ligament and meniscus in his left knee. He returned in September and batted .290 for the season in 69 games. He was Tampa's everyday second baseman when the Rays went to the World Series in 2008 and batted .274 with six homers, 48 RBIs and a .349 on-base percentage.
"He is a good athlete with above-average speed and is a tough out with a solid career on-base percentage," Pirates general manager Neal Huntington said. "Additionally, he played Gold Glove-caliber third base for years in Japan and has made a smooth transition to second base."
Once the Rays determined they were not going to pick up Iwamura's option for 2010, Friedman listened to offers for a trade.
"Pittsburgh has been all over us for about a month," Friedman said.
Chavez led Pittsburgh and all major league rookies with 73 appearances in 2009, going 1-4 with a 4.01 ERA in 67 1/3 innings. He was taken in the 42nd round in 2002 by Texas, and made his major league debut with the Pirates with 15 appearances in 2008.
The Rays believe the 26-year-old has the potential to develop into an outstanding reliever.
"This year was a good year," Friedman said. "We feel like he has the tools and ability to have an even better year."
Iwamura was a five-time All-Star and six-time Gold Glove third baseman in Japan. In three seasons in Tampa Bay, he batted .281 with 14 homers, 104 RBIs and 29 stolen bases while playing third base for one year and second for the past two.
His unselfish transition from third to second base in 2008 -- a move that opened a position for All-Star Evan Longoria -- was one of the keys to Tampa Bay's transformation from a perennial last-place team into AL champions.
"It is hard to put into words what Aki has meant to the organization," Friedman said.
Pittsburgh takes on Iwamura's option, which the Pirates can pay because their already low payroll was trimmed when they dealt Sanchez, Adam LaRoche, Jack Wilson, Nate McLouth, Nyjer Morgan and Eric Hinske during the season.
Coming off a major league-record 17th consecutive losing season in which they lost 99 games, the Pirates also needed to make a move to at least appease a dwindling fan base that was angered by yet another season of player departures.
Buster Olney covers MLB for ESPN The Magazine. Information from The Associated Press was used in this report.