The Sharks also get forward Nick Spaling, while the Maple Leafs get second-round picks in the 2017 and 2018 drafts.
Polak, 29, has one goal and 12 assists and a plus-minus of 8 this season in 55 games for the Leafs. He is making $3.1 million in 2015-16, the last season of a five-year contract he signed with the St. Louis Blues in 2011. Toronto acquired him in a 2014 trade.
Both Polak and Spaling are scheduled to become unrestricted free agents after this season.
San Jose general manager Doug Wilson calls Polak and Spaling "quality, character players."
The Leafs said the 34-year-old Torres will be reassigned to the San Jose Barracuda of the AHL. The longtime NHL veteran hasn't appeared in an NHL game this season as he served a 41-game suspension for a hit to the Anaheim Ducks' Jakob Silfverberg during a preseason game. He missed all of last season with a knee injury.
Torres, who has 137 goals and 123 assists in 635 career games, is making $1.5 million in 2015-16, the last year of a three-year contract he signed with the Sharks in 2013. He played just 12 regular-season and playoff games combined in his final three seasons with the Sharks.
The Sharks needed to include his contract to make the deal work under the salary cap.
"Raff is a good man,'' Sharks general manager Doug Wilson said. "He's been on a tough journey. He just needs more time to go get healthy and go on with his career. This was a necessary part of this deal to make it work cap-wise and financially.''
Maple Leafs general manager Lou Lamoriello said defenseman Stuart Percy and forward Brendan Leipsic will be recalled from the team's AHL affiliate (the Toronto Marlies) to fill the two open roster spots following Monday's trade.
The trade is the Leafs' second in two days. On Sunday, Toronto traded forward Shawn Matthias to the Colorado Avalanche for forward Colin Smith and a fourth-round pick in the 2016 draft. Toronto has been clearing salary and acquiring draft picks as part of a major rebuild. The Leafs traded captain Dion Phaneuf to the Ottawa Senators on Feb. 9.
San Jose is third in the Pacific Division, three points behind Anaheim and five points behind Los Angeles.
The Associated Press contributed to this report.