"It was nice, but games are so important right now," said Gallagher, who has nine two-goal games in his career. "It's a pretty good feeling to come out with two points. We're heading on a little bit of a tough road trip here, so we're feeling good about ourselves, hopefully we continue it and it carries over."
Jesperi Kotkaniemi and Tomas Tatar scored for the Canadiens (33-21-7), who have won two straight following a four-game losing streak. They lead the Carolina Hurricanes by three points for the first wild card into the Stanley Cup Playoffs from the Eastern Conference and trail the Toronto Maple Leafs by three points for third place in the Atlantic Division.
[WATCH: All Flyers at Canadiens highlights]
Carey Price made 29 saves for his 311th win, three behind Jacques Plante (314) for most by a Montreal goalie.
"He made some pretty good saves tonight," Flyers captain Claude Giroux said. "That's the reason why he's one of the best goalies in the League, and he does it every night. I feel like we had some good chances against him."
Video: PHI@MTL: Price turns away Simmonds, Laughton
Philadelphia (28-26-7), which has lost two in a row after a three-game winning streak and is seven points behind Carolina for the second wild card, will host the Pittsburgh Penguins in the 2019 Coors Light NHL Stadium Series at Lincoln Financial Field on Saturday.
Flyers rookie goalie Carter Hart was pulled in the first period after allowing three goals on nine shots for the second straight game (5-2 loss to the Tampa Bay Lightning on Tuesday).
"There's obviously a couple of bounces that didn't go my way, just like the other night," he said. "You look at these past two games and you put it behind you, but you learn from it. And I know it doesn't feel great right now, but you learn from it, you try to take the positives out of it and see what you can improve on, and just put it away."
Hart, making his fourth straight start, was relieved after Gallagher's second goal of the game made it 3-0 at 10:33 by Brian Elliott, who made 29 saves.
"We didn't give him a chance to even get in the game," Flyers coach Scott Gordon said of Hart. "The chances that we gave up right off the bat there, they were pretty good shots. And I'm sure knowing Carter he's going to say, 'I should have had them,' you know, 'I've got to make saves there,' and all of that. But at the end of the day, we can't give up those chances for the wrong reason."
Gallagher, who gave Montreal a 1-0 lead 58 seconds into the game, scored his third goal of the night, his Canadiens-leading 26th, at 2:56 of the second to make it 4-0.
Video: Enterprise Hat Trick: Gallagher nets three
Tatar made it 5-0 at 6:48 to reach 20 goals for the fifth straight season.
"A lot of things worked out for us tonight," Tatar said. "We had a lot of jump from the get-go, and I think it was a deserved win."
Michael Raffl scored for the Flyers at 10:23 to make it 5-1.
Gallagher's first goal was the sixth time Montreal scored in the first minute of a game, tied with Carolina for most in the NHL.
Kotkaniemi made it 2-0 at 3:11 when he scored his 11th goal on a pass from Byron.
"I thought we had some good shifts in the offensive zone, which we didn't have against Tampa Bay," Gordon said. "We obviously didn't score, but we had some in-zone time and usually that trends into a positive direction, and it didn't, because when you make those kinds of mistakes, you know, reads on the forecheck and then your turnovers, it doesn't really matter how much time you spend in the offensive zone, you can't make up for those mistakes."
Video: PHI@MTL: Kotkaniemi buries feed from Byron
They said it
"We need to find a way to deal with big games, and a game like tonight we definitely need to be better." -- Flyers captain Claude Giroux
"There's nothing harder to defend than when you're facing some speed to defend. Our transition game has been pretty good. Guys coming back hard gives you the opportunity to turn up the ice and go back with some speed, instead of maybe being lazy, being up high receiving a pass, you're standing still you've got no support, so that's been very helpful for our team this year." -- Canadiens coach Claude Julien
Need to know
Kotkaniemi is the third player in NHL history to score each of his first 11 goals at home along with Bobby Sheehan (13) and Sheldon Souray (11). … Price is 7-0-1 in his past eight home games.
Flyers: Host the Pittsburgh Penguins in the 2019 Coors Light NHL Stadium Series at Lincoln Financial Field on Saturday (8 p.m. ET; NBC, SN360, SN1, TVAS2)
Canadiens: At the Toronto Maple Leafs on Saturday (7 p.m. ET; ESPN+, CBC, SN, CITY, TVAS, NHL.TV)
Video: Gallagher's first hat trick leads Canadiens by Flyers