Erik Christensen, Bryan Little and Vyacheslav Kozlov scored for Atlanta, which had dropped six straight games before its five-game streak.
Kozlov hammered in a rebound at 12:03 of the third period to pull the Thrashers back from a two-goal deficit to a 3-3 tie.
One minute later, Lupul skated in from center ice, slipped around a defender at the face off circle, and put a slap shot from the slot between goalie Johan Hedberg's pads.
Niittymaki, who blanked the Thrashers 7-0 with 24 saves earlier this season, is 11-0 against Atlanta. He stopped 21 shots in the third period.
Niittymaki is one of only two active goaltenders in the NHL with a perfect record in at least 10 decisions against one team. Chris Osgood, of the Detroit Red Wings, is 17-0 against Tampa Bay.
Niittymaki helped preserve the Flyers' lead in the second period when the Thrashers had a two-man advantage for 1:12. He's 2-1-2 this season.
Hedberg had 28 saves for Atlanta.
Gagne scored unassisted to put the Flyers ahead 53 seconds into the first period. He picked up a loose puck deep in the Flyers' zone, skated in, and went forehand to backhand for his 11th goal. Knuble made it 2-0 with 7 seconds left in the period. He scored his seventh goal on a wrist shot from the left circle after taking a cross-ice pass from Gagne.
Christensen got Atlanta on the board at 5:45 of the second period when his shovel shot from the slot trickled past Niittymaki. It was his first goal in 19 games dating to last March.
Timonen put the Flyers ahead 3-1 with a slap shot from behind the left circle on a power play at 11:27. Knuble picked up his 200th career assist on the goal.
Little got Atlanta to within 3-2 with a fluke goal 35 seconds into the third period. Niittymaki stopped his first shot, but the puck bounced off Philadelphia defenseman Luca Sbisa back into the net.
Notes: Philadelphia held the Thrashers to four shots in the first period, tying a one-period season low for the Flyers. ... Atlanta C Little extended his point scoring streak to six games (4 goals, 5 assists). ... Gagne extended his points streak to five games (3 goals, 5 assists). ...Philadelphia C Mike Richards had his career-high eight game streak (13 goals, 15 assists) snapped. ... The Flyers are 13-0-1 in the last three seasons against the Thrashers.