Max Pacioretty sealed the win with an empty-net goal with one second remaining.
It was the first time this season the Senators were shut out. Montreal won the best-of-seven series in six games but lost two in a row after taking a 3-0 series lead -- and Ottawa nearly sent it to a deciding seventh game. The Canadiens will face the winner of the Detroit-Tampa Bay series, which the Red Wings lead 3-2.
"I know some people thought it would be pretty easy for us to get the fourth win, but we knew they were a capable team that battled hard all season to get into the playoffs," Subban said. "I like the way we had to win this series.
"We deserved it. We worked for it. I thought we had some bounces early in the series. We didn't get them as the series went on, but today we stuck to the plan regardless of what happened. And when you have Carey Price back there, it makes everything a lot easier."
Price, nominated for the Vezina Trophy as the league's top goalie, rebounded after allowing five goals in Game 5 with a masterful effort as the Senators outshot the Canadiens 43-20.
Montreal, which reached the Eastern Conference finals last spring, is in the second round for a second consecutive year for the first time since 1992 and `93. "Advancing is such a great feeling, but we have to be honest: We got some bounces tonight,'' Pacioretty said. "They poured it on us pretty good, and Carey was a wall back there."
After controlling the game early, the Canadiens got the first goal for the first time in the series when Gallagher took Greg Pateryn's high shot off his body and batted it past Craig Anderson at 13:26.
"It hit my arm and I felt it go that way, so I spun around, found the puck and was fortunate to put it in," Gallagher said. "You don't plan on whacking them out of the air all the time, but I was able to catch the goalie out of his position."
Montreal had the first six shots of the game, but the Senators outshot them 16-3 in a dominant second period in which they did everything but score.
The 20,500 fans at the Canadian Tire Centre were screaming for a call of too many men on the ice against Montreal when referee Chris Lee blew the whistle just before Jean-Gabriel Pageau put a puck in at 6:55 that had fallen past Price -- so the goal didn't count. "It was just bad puck luck," Ottawa coach Dave Cameron said about the disallowed goal.
With former Senators star Daniel Alfredsson cheering from a luxury box, Ottawa went all out in the third for the equalizer, but Montreal finished with strong checking and two or three more solid saves from Price.
"That's what it's all about," Price said about the frantic final minute. "That's what makes it fun. Since you're a little kid, you dream about being in those situations."
A late tripping call on Jacob de la Rose gave Ottawa a last chance on the power play, and near the end of it pulled Anderson for a two-skater advantage. Late-season pickup Torrey Mitchell tied up two faceoffs in the Montreal end, Price made some stops and Pacioretty finally put it away.
"This team has been a real treat,'' Cameron said. "We got beat by a pretty good hockey club and, when we get over it, we'll feel pretty good about what we accomplished here."