Claude Giroux and Jakub Voracek each had a goal and two assists, and Wayne Simmonds and Erik Gustafsson also scored for the Flyers (18-21-3), who matched their season high for goals as they try to make a late push for a playoff spot.
Philadelphia is in 12th place in the Eastern Conference, four places and seven points behind the New York Rangers and the postseason cutoff. The Flyers have six games remaining, starting with a home matchup with the Rangers on Tuesday.
Max Pacioretty, Brendan Gallagher and Alex Galchenyuk scored for the Canadiens (26-10-5), who were coming off a 5-1 loss in Toronto. They have had two lopsided losses since clinching a playoff spot on Thursday.
The Flyers outshot Montreal 33-28 in a sloppy game that had the 21,273 at the Bell Centre booing the Canadiens.
Carey Price was pulled for a second game in a row in favor of Peter Budaj. Price left at the end of the second period after allowing six goals on 29 shots.
Montreal's Ryan White was ejected in the first period for a direct hit to the head of defenseman Kent Huskins, when the Canadiens were trailing 2-0 just 6:11 in. The Flyers said Huskins had a concussion, and he didn't return to the game.
White launched himself at Huskins, but missed his body and caught him on the jaw.
Price, pulled in Toronto on Saturday after allowing three goals on four shots, gave up two goals on five Philadelphia shots before settling down. The Flyers outshot Montreal 17-8 in the first period.
Simmonds broke down right wing and fired a shot that was stopped by Price, but the rebound hit rookie Montreal defenseman Nathan Beaulieu and went in at 2:45.
Gustafsson's wrist shot from the point went through several bodies in front and trickled between Price's pads at 5:49.
Consecutive cross-checking calls on the Flyers' Oliver Lauridsen allowed the Canadiens to tie it as Pacioretty tipped in Tomas Plekanec's pass in the slot at 19:02. Gallagher scored from in front 38 seconds into the second.
Only 24 seconds later, Josh Gorges overskated a puck behind his net, and Claude Giroux pounced and fed Voracek as the Flyers took a 3-2 lead. Voracek's 18th goal tied a career high set last season.
Hartnell scored from the slot on a power play at 7:30, but Galchenyuk fought off a check to score at 9:11. Giroux put one in off Andrei Markov's stick at 10:46 for a 5-3 Philadelphia lead.
Hartnell snapped a shot past Budaj from the top of the left circle 12:45 into the third.
NOTES: A moment of silence was held for victims of the Boston Marathon bombing. ... Montreal rested banged-up forward Brandon Prust. White took his place in the lineup.