Andersen, 26, has also agreed to a five-year extension with the Leafs that carries an average annual value of $5 million, according to a source. He was to become a restricted free agent on July 1.
"We were too far apart, I think," Andersen said of his negotiations with Anaheim. "I'm just happy about being in a big hockey market. It's going to be a lot of fun developing with this young team that's very hungry for success."
In exchange, the Ducks will get Toronto's 30th overall pick this year, plus a second-rounder next year.
"When you get a goaltender of this caliber, with the experience he's had and the success ... I think acquiring them is the most important thing," Toronto general manager Lou Lamoriello said. "The price was secondary."
With Jonathan Bernier already on their roster, the Leafs made upgrading their goaltending a top priority.
Anaheim has young John Gibson in goal and was long rumored to be putting Andersen on the trade market this offseason.
"We're going forward with a guy that's three, four years younger, a guy that had one of the top five goals-against in the league, and won the Jennings Trophy already," Ducks general manager Bob Murray said. "I'm not worried about what I've got left, and we'll go and get a good backup. It's just about managing your assets."
Information from The Associated Press was used in this report.