While the team didn't disclose terms, multiple reports say he will receive $11.5 million per season, making him the highest-paid defenseman in the league. The Kings' Drew Doughty had held that distinction after signing an eight-year, $88 million deal last summer.
"We are extremely pleased that Erik and his wife Melinda have committed to the San Jose Sharks and that they have done so prior to July 1," Sharks general manager Doug Wilson said in a statement. "Players with Erik's elite level of talent are rare and when they become available, it's important to be aggressive in pursuing them. He is a difference maker who consistently makes the players around him better. We are pleased that he has been proactive in addressing his injury from last season and are looking forward to him being part of our organization for a long time to come."
The Sharks acquired the six-time All-Star and two-time Norris Trophy winner from the Senators in September. Since he re-signed with San Jose, Ottawa gets a second-round draft pick.
Per the NHL CBA, the Sharks were the only team that could offer Karlsson eight years; as an unrestricted free agent, another team could only go as high as seven.
Karlsson, 29, had a down year offensively as injuries limited him to 54 games this past season. His three goals were the lowest of his career. His 45 points were the lowest since 2012-13, when he played only 17 games for Ottawa.
Karlsson had 62 points for the Senators last season, 71 the year before that and a career-high 82 in 2015-16.
"I'm super excited to continue my journey with the Sharks," Karlsson said in the statement. "Since my first day here, I have only good things to say about the people, organization and the fans. The entire Bay Area has been extremely welcoming to me and my family. I appreciate that and we can't wait to spend the next eight years in San Jose.
"As far as hockey goes, I'm excited to continue the chase for the ultimate prize: the Stanley Cup. Last year was an unbelievable run but we didn't achieve what we set out to do. But the dedication I witnessed from my teammates, coaches, staff and organization showed me that we all have a great future ahead of us, and that we are capable of fighting for that championship year in and year out."
The Sharks lost to the eventual Stanley Cup champ Blues in six games in the conference finals.