The Sharks trailed 2-0 but got a goal from Jason Demers in the second period and an equalizer from Joe Pavelski in the third.
After a scoreless overtime, the shootout remained scoreless until the fourth round when Thornton used a forehand shot under Lehtonen's blocker to give San Jose the advantage. Sharks goalie Alex Stalock then stopped Ray Whitney to seal the win -- San Jose's third in five games.
Stalock turned aside 42-of-44 shots.
Whitney and Antoine Roussel scored for the Stars. Lehtonen finished with 37 saves.