After St. Louis' fourth goal of the game had given the Lighting a 4-2 lead 2:07 into the middle period, Pavelski got the next three scores, including the go-ahead goal on the tip-in of a Matt Irwin shot with 1 minute remaining in the second.
It was the first career hat trick for Pavelski, who has 25 goals on the season.
Patrick Marleau added a goal and two assists and Matt Nieto supplied a goal and an assist for the Sharks, who completed a perfect 3-0-0 Eastern Conference road trip.
Antti Niemi stopped 25-of-29 shots.
St. Louis notched the first four-goal game of his career. He also has 25 goals for the season.
Tyler Johnson and Teddy Purcell each supplied two assists and Ben Bishop made 27 saves for the Bolts, who have lost three of their last four games.