The team announced the deal Wednesday.
Mayers says he was looking to join a team that gave him the best chance to win. San Jose made it to the Western Conference final last season before losing to the eventual champion Chicago Blackhawks.
Mayers has played 737 career games with the St. Louis Blues, Maple Leafs and Flames. He has 81 goals, 107 assists and 969 penalty minutes.
The Sharks have also re-signed minor league center Steven Zalewski to a one-year contract.