Joe Pavelski and Logan Couture scored, and Martin Jones made 14 saves for San Jose (35-17-8), which trails the Calgary Flames by one point for first place in the Pacific Division.
Thornton's hat trick was the fifth of his NHL career and the 39-year-old's first since Oct. 27, 2010, against the New Jersey Devils. It was the 15th time in NHL history that a player 39 or older had a hat trick.
"I can believe it," Thornton said of the nine-year stretch between hat tricks. "I don't shoot it too often, so yeah. But it was a good feeling."
Thornton, the No. 1 pick in the 1997 NHL Draft by the Bruins, scored his third goal at 13:32 of the third period to give the Sharks their first lead of the game, 5-4.
"It was a spectacular night for him, considering it's [against] his first NHL team, the history behind that," Sharks coach Peter DeBoer said. "Couldn't have written a better script other than winning the game."