The Maple Leafs trailed 5-2 after Flyers defenseman Shayne Gostisbehere scored at 13:27 of the second period.
"It was pretty crazy. We showed a lot of resilience, never quit," said Toronto center Auston Matthews, who scored twice in the third period, including the go-ahead goal. "I think everybody in this locker room, we had a mindset that no matter what, we were going to come out and win this game."
WATCH: [All Flyers vs. Maple Leafs highlights]
Jake Muzzin scored two goals and had an assist for the Maple Leafs (43-23-5), who avoided losing three games in a row in regulation for the first time this season and trail the Boston Bruins by two points for second in the Atlantic Division.
"It's nice to come back and win. Two points is crucial for us," Muzzin said. "We'd like to do it in a different manner, but a win is a win. We showed a lot of character in the room here, not getting frustrated and just sticking with our program."
James van Riemsdyk had a hat trick, and Brian Elliott made 44 saves for the Flyers (34-29-8), who were coming off a 5-2 loss to the Washington Capitals at home Thursday. Philadelphia trails the Carolina Hurricanes by seven points for the second wild card into the Stanley Cup Playoffs from the Eastern Conference.