The team announced the deal Tuesday. Lehner was a restricted free agent.
The 26-year-old Swede showed he could stay healthy last season, setting career highs with 59 games played, 23 wins and two shutouts. He ranked third in the NHL with 1,758 saves and finished with a .920 save percentage and 2.68 goals-against average.
Bothered by injuries and concussion problems, Lehner had never before played more than 36 games in an NHL season. The Sabres took a chance on Lehner when they traded a first-round pick to the Ottawa Senators for him at the 2015 draft.
Lehner will again be a restricted free agent next summer when this contract expires.