The Pacific Division-leading Flames went up 3-1 early in the second before the Sharks responded with goals from Erik Karlsson, Logan Couture and Hertl to take the lead in the opener of a seven-game homestand, San Jose's longest of the season.
''It was huge because when you come back from long trips the first game is the hardest,'' Hertl said. ''This homestand is really important and I think a really great effort from tonight.''
Hertl sealed it with an empty-netter for his first hat trick since Jan. 22, 2019, against Washington. Hertl, who snapped a five-game point drought with a goal Sunday, also scored on the power play in the first.
''Every player in this league goes through ups and downs, and when he gets hot he is so good,'' Couture said. ''It's so important to our team.''
Adin Hill made 40 saves for the Sharks.
Dillon Dube, Johnny Gaudreau and Adam Ruzicka scored for the Flames, who dropped the final two games of a four-game trip that started with two wins. Dan Vladar made 22 saves.
''I think probably our defense had a really rough night,'' coach Darryl Sutter said. ''The goaltender had trouble in traffic and with rebounds. ... I'd say the six defensemen played like it was an exhibition game. Disappointing.''
Ruzicka scored his first career goal early in the second when he knocked in his own rebound before the Sharks got going in the second half of the period.
Karlsson started it shortly after returning to the ice following his delay of game penalty, scoring his seventh of the season on a breakaway off a pass from Couture.
The two then flipped roles on the power play when Couture redirected Karlsson's point shot for the equalizer.
Hertl scored on a rebound from the side of the net on a power play with 1:50 left in the second to put San Jose ahead for the first time.
The Flames came up empty on three power plays.
''We had a ton of opportunities to make it a 4-1 game there at one point,'' Gaudreau said. ''We didn't and we let them hang around. I thought we were playing well, 5 on 5, but our power play, we have to find a way to put the puck in the net.''
The Flames entered as the NHL's best team in the first period with a plus-16 goal differential and added to it against the Sharks.
After a turnover by Brent Burns in the neutral zone, Dube redirected a centering pass from Milan Lucic to open the scoring 1:37 into the game.
After Hertl tied it on the power play, Matthew Tkachuk won a puck battle behind the net and found Gaudreau with a no-look pass alone in front to make it 2-1.
The assist gave Tkachuk his 300th career point in his 375th game. He joins Auston Matthews as the only players from the 2016 draft class to record 300 points so far in the NHL.
The Sharks benched forward Kevin Labanc, who has no points in the last six games and just two even-strength points in 19 games this season. San Jose also placed forward Rudolfs Balcers on injured reserve with a lower-body injury and said he is week-to-week.
The Sharks recalled goalie Alexei Melnichuk from the AHL to back up Hill. James Reimer missed his fourth straight game with a non-COVID-19 illness.
Flames: Host the Carolina Hurricanes on Thursday.
Sharks: Host the streaking Minnesota Wild on Thursday.
More AP NHL: https://apnews.com/hub/nhl and https://twitter.com/AP-Sports
Copyright 2022 STATS LLC and Associated Press. Any commercial use or distribution without the express written consent of STATS LLC and Associated Press is strictly prohibited.