SAN JOSE, Calif. -- Joe Pavelski ended his streak of bad luck.
"There were some looks out there," Pavelski said. "It's been working out so far but we have to keep chipping and make it an everyday thing. We made it a little tough for ourselves, but it was a good win at the end."
Ryane Clowe and Logan Couture also scored for the Sharks, who have won three of four.
Couture had a career-high three points, adding a pair of assists, as he continues to flourish on the second line that also includes Clowe and Pavelski.
"I feel like the puck is falling for me in the offensive zone," Couture said. "Clowe is such a great playmaker and goal scorer that things are going well for me."
Jay Bouwmeester, Mark Giordano and Jarome Iginla had goals for the Flames, who have lost six of seven.
"It just seems that same old thing of one or two mistakes is really killing us, costing us games," Giordano said. "We did a lot of good things again, but a big goal here or there gave them momentum."
Antti Niemi started for the second time since Oct. 27, recording 28 saves for his second win in six decisions. Ex-Shark Miikka Kiprusoff took the loss despite 31 saves.
"After facing a few shots I started feeling pretty comfortable," Niemi said. "I've been trying to work on the basic things, and hard work always pays off."
Pavelski, the team's leader in shots, missed on his previous 67 attempts before connecting in the second period on a rebound.
The Flames, playing the second of back-to-back road games, took a penalty in the opening minute of play. That led to Thornton's sixth goal of the season 8 seconds into the power play.
"Here we've lost six of our last seven and that urgency has to be there," Flames coach Brent Sutter said. "We're only in the middle of November and we have to have that now."
Thornton positioned himself to receive a nice pass from Jason Demers and was able to beat Kiprusoff.
Clowe added his third goal of the season midway through the first period with an assist from Pavelski on a give-and-go.
"They have been our best line," Sharks coach Todd McLellan said. "They're around the net and when you're playing as hard and doing the right things as they've been, eventually you're going to get rewarded."
Dan Boyle chipped a puck over the glass six seconds into the second period to create a 5-on-3 advantage for the Flames -- Dany Heatley took a boarding penalty late in the first period -- and Giordano took advantage with some crisp passing from Ian White and Iginla.
Pavelski's goal gave the Sharks a 3-1 lead heading into the third period.
Bouwmeester scored midway through the final period and Couture responded with his sixth goal 5 minutes later.
Iginla scored with 37 seconds remaining.
The Flames gave up the first goal for the second time in 12 games and fifth overall. ... Clowe's assist on Pavelski's goal was the 100th of his career. ... Flames C Brett Sutter, briefly jailed on suspicion of assault after getting into a fight outside a Scottsdale bar early Thursday, was a healthy scratch for the 12th straight game. ... Boyle has five points in his last four games.