Martin Biron made 27 saves and Mike Richards added a power-play goal for the Flyers, who strengthened their hold on fourth place in the Eastern Conference with their second straight win and eighth in 12 games.
Carter is third in the NHL with 38 goals, but he found the net just twice in the previous 12 games. Flyers coach John Stevens said part of the problem was Carter wasn't shooting enough.
"Sometimes when you aren't scoring, you don't shoot and you wait for the perfect opportunity," Stevens said. "He shoots the puck so well that if he keeps shooting it, good things happen."
Carter agreed with Stevens' assessment that he and linemates Joffrey Lupul and Hartnell were trying to be too creative with their passes.
"We cut back on being too fancy," Carter said. "If you go for cross-ice passes a lot, sometimes they get picked off."
Maxim Afinogenov and Jochen Hecht scored for Buffalo, which is locked in a tight race for a playoff berth. The Sabres are 10th in the East, but came in only three points out of a playoff spot and four points out of fifth.
"It was a tight game and then in the third period we made some mistakes that we shouldn't have made," Afinogenov said. "A couple of mistakes cost us."
Carter and Lupul combined for two goals during a span of 6:17 in which the Flyers scored three times to snap a 1-all tie.
The Flyers carried momentum from a fast-paced second period into the final frame. Just 27 seconds in, Lupul found Carter streaking toward the net and put a perfect pass on his stick. Carter slid a shot past Patrick Lalime for a 2-1 lead.
"If I have a chance to shoot, I'm going to shoot it," Carter said.
A few minutes later, Richards redirected Kimmo Timonen's slap shot for his 26th goal.
Then, Carter and Lupul did it again on a 2-on-2 rush. Lupul skated in from the blue line and slid a pass through two defenders to Carter, who beat Lalime for his 38th goal.
Lalime was replaced by Mikael Tellqvist after giving up the goal. Lalime made his seventh straight start filling in for Ryan Miller, who is out indefinitely with a high left ankle sprain.
Hartnell scored his second goal when the puck bounced off his chest and went in late in third.
"You get in trouble when you go east-west and make cute passes," Hartnell said.
The Flyers again were without center Daniel Briere, who sat out his second straight game after aggravating a groin injury last week. Briere has missed 53 games in his second season since signing a $52 million, eight-year contract with Philadelphia. He practiced Monday and was hoping to play against his former team.
The Sabres took a 1-0 lead on Afinogenov's goal just 1:52 in. Teppo Numminen's shot from along the boards deflected off Afinogenov's left skate and bounced over Biron's shoulder.
Afinogenov had a chance at another goal later in the period, but Biron gloved his point-blank one-timer.
"We gave ourselves a chance to win in the third period, but we came out not very good," Sabres forward Thomas Vanek said. "It's disappointing because there are so few games remaining."
Hartnell's power-play goal with 12 seconds left in the first tied it at 1. Claude Giroux set it up with a nifty cross-ice pass.
The Flyers are 3-0 against Buffalo this season, outscoring the Sabres 9-1 in the third period. ... Afinogenov, a three-time 20-goal scorer, has three goals in 37 games this season. ... Biron improved to 3-0 against his former team this season. ... The Sabres had allowed just two power-play goals in the last 32 chances, before the Flyers scored on consecutive opportunities. ... Flyers F Riley Cote left with an upper-body injury. ... The Phillies' World Series trophy was in the building along with the Phillie Phanatic.
Copyright by STATS LLC and The Associated Press
Arena: Wells Fargo Center Location: Philadelphia, Pennsylvania
Referees: Rob Martell, Tim Peel Linesmen: David Brisebois, Steve Barton
Attendance: 19,421 (99.6% full)
Team Stat Comparison
Power Play Goals
Power Play Opportunities
Shots on Goal
Maxim Afinogenov (3)
Assist: Teppo Numminen
Scott Hartnell (23)
(Power Play) Assists: Claude Giroux, Mike Richards
No scoring this period
Jeff Carter (37)
Assists: Joffrey Lupul, Scott Hartnell
Mike Richards (26)
(Power Play) Assists: Kimmo Timonen, Simon Gagne
Jeff Carter (38)
Assists: Joffrey Lupul, Scott Hartnell