Both star forwards were slated to become unrestricted free agents July 1.
Marleau gets an average salary of $6.66 million, while Thornton, the team captain, will make $6.75 million per year, a source told ESPN.com.
"We really appreciate them helping us keep this group together and contributing in this way," general manager Doug Wilson said. "They both did step up. It says a lot about both of them as people and teammates."
Selected second overall by the Sharks in 1997, Marleau has 21 goals and 47 points in 51 games this season. The 34-year-old has 425 goals and 908 points in 1,216 games.
The 34-year-old Thornton, acquired from the Bruins during the 2005-06 season, leads the league with 47 assists. He has 337 goals, 834 assists and 1,171 points in 1,176 games. His deal includes a full no-movement clause.
Both insisted on waiting to sign until knowing the other player was coming back, too.
"That created a unique dynamic in the negotiations because it was two individual negotiations but it was contingent to them knowing we're a better team with both instead of one," Wilson said. "That tells you the respect between the two players."
Despite all the regular-season success, San Jose is still searching for its first trip to the Stanley Cup finals. The Sharks lost the Western Conference finals in 2010 and 2011, and were knocked out in seven games in the second round last season against Los Angeles. San Jose is poised for another run this season and is currently fifth in the league with 72 points.
Thornton and Marleau are still playing at an elite level. Thornton is sixth in the league this season with 53 points. Marleau was picked for the Canadian Olympic team.
"They're elite level players that are still playing at elite levels," Wilson said. "They're only 34 years of age. They are both strong and healthy and very high fitness guys."
With these deals done, the Sharks have locked up almost all of their important players before free agency starts in July. The one key remaining potential unrestricted free agent is 37-year-old defenseman Dan Boyle, who is in talks with the Sharks about a new deal.
"We think we're set very well for the future, and we also think we're in a very good position to focus on the now," Wilson said.
Information from The Associated Press was used in this report.