Jokinen also had an assist while Jarome Iginla added a goal and an assist for the Flames, who had dropped three of four coming into the contest.
Miikka Kiprusoff stopped 34 shots for the 300th win of his career.
"It's a nice number," Kiprusoff said. "Right now it's not that big a deal. It's nice, but we have a job to do here. We're fighting for the playoffs, and we need those wins. But, yeah, it's a good number."
San Jose had tied the game at 3-3 just 49 seconds into the third on the power play when Handzus jammed it in during a scrum in front.
However, Jokinen finished the hat trick less than three minutes later. A bad clear in the San Jose end saw the puck take a bounce off the boards along the right wing as Alex Tanguay picked it up and fired a pass down low where Jokinen one-timed it home.
Kiprusoff stopped 14 shots in the final period to preserve the win.
It was a 1-0 lead for Calgary at the 12:30 mark of the first after Chris Butler blasted a shot on net from the left point that hit off of Jokinen and went past Niemi.
The Flames took a 2-0 lead 2:36 into the second on the power play as Jokinen jammed the puck in from the right side.
The Sharks got one back at the 6:29 mark as Couture beat Kiprusoff with a wrister from the right circle and the team tied the game just 1:23 later when Joe Thornton sent a pass from behind the net to the slot and Pavelski shot it in for his 20th of the season.
"It's a missed opportunity," Thornton said. "We'd like to say we played good at times, it just wasn't a full 60 [minutes]."
Calgary made it a 3-2 game with 8:45 to play in the second as Jokinen sent a backhand pass from the right wing to the slot where Iginla one-timed it home.
Calgary plays in Phoenix on Thursday...San Jose hosts Chicago on Friday...San Jose had won the previous five games against Calgary, including two games this season...Pavelski is just five goals away from tying a career-high...Jokinen has 16 goals on the season.