The Cubs also announced that free agent pitcher Kerry Wood had signed a one-year deal worth a reported $1.75 million.
Under the terms of his previous contract, Ramirez was guaranteed $22.5 million over the next two years but had an opt- out clause that allowed him to file for free agency after the 2006 season.
The 28-year-old had expressed a desire to stay in Chicago and agreed a new long-term deal that includes a mutual option which could keep him in a Cubs uniform through 2012.
Trachsel joins Orioles
"It was a situation, obviously, where I think at the end of the day, the player did want to be here," Cubs general manager Jim Hendry told MLB.com. "It's not much of a secret, the figures that were being bantered around would've been much higher.
"As good a deal as this is for any player, I certainly believe there was a six- or seven-year deal guaranteed out there that would've paid him $20 million more than he got.
"He was the lucky beneficiary of being a free agent at a time when his services were needed. The people of Chicago should be glad to know that he did leave a lot out there."
Ramirez, who set a career-high with 38 home runs and 119 RBIs in 2006, was coveted by several teams and could have commanded huge offers if he had hit the free agent market.
"If he hits the market, we'll be looking at (Carlos) Beltran money," Ramirez's agent Paul Kinzer told the Los Angeles Times. Beltran signed a seven-year, $119 million deal with the New York Mets in 2004.
In three seasons in Chicago, Ramirez has 120 home runs and 353 RBIs in 488 games.
After watching Wood battle shoulder problems for the last three years, the Cubs opted not to pick up his $13.5 million option but instead paid the righthander a $3 million buyout and resigned him to a new incentive laden deal that could pay him as much as $6 million next season.
Wood appeared in just four games, posting a 1-2 record and 4.12 ERA.
Brewers sign Suppan in record deal
McCarthy joins White Sox