The 32-year-old Fehr played in four games with the Leafs this season. He was loaned to the AHL's San Diego Gulls in November, where he's had 17 goals, 11 assists and 33 penalty minutes in 34 games with San Diego.
The Sharks are in a tight race with Anaheim for second place in the Pacific Division.
Fehr, a 2003 first-round pick of Washington, has 103 goals and 99 assists in 566 NHL games with Washington, Winnipeg, Pittsburgh and Toronto.
The swap means Toronto has eight picks in the 2020 draft.