Jeremy Swayman made 26 saves for his ninth win in his past 10 starts for Boston (39-19-5), which has won five of its past six games.
"First place, last place, somewhere in between, either team, it's still a passionate game," coach Bruce Cassidy said. "I thought that's what took place tonight. Both teams were into it. They were physical early, had a couple of big hits and we tried to respond with that and let the game play out. I thought it was a good hockey game. Either team could have won."
Allen made 43 saves for Montreal (17-36-10), which traded forward Artturi Lehkonen, defenseman Brett Kulak and goalie Andrew Hammond earlier in the day.
"It's tough. It's part of the business," Allen said. "I think we all knew there was potential of this [happening] today. We didn't know if anything was actually going to happen, and we got up from our naps and saw the news, and it is what it is. Those guys have great opportunities now to go in the playoffs and earn themselves some new contracts and go for a Stanley Cup, so you've got to be happy for them."
Allen is 1-0-2 since returning from a lower-body injury on March 17. He missed 25 games.
"It's tough to lose a game like that," Canadiens defenseman David Savard said. "Jake played really, really well. He made some big, big saves to keep us in the game."
Joel Armia gave Montreal a 2-1 lead at 1:13 of the third period when he scored shorthanded on a 2-on-0 after intercepting Marchand's pass attempt to Charlie McAvoy.
"I was just really happy that we didn't lose because of that turnover," Marchand said.
Connor Clifton tied it 2-2 with 2:59 remaining in the third.
Marchand gave Boston a 1-0 lead at 9:21 of the first period moments after exiting the penalty box. He tapped in Haula's pass from the goalmouth.