MONTREAL – The Montreal Canadiens stopped their longest slide of the season just in time to avoid dropping out of the Northeast Division lead.

Max Pacioretty had a goal and an assist and Scott Gomez also had two points as Montreal ended a three-game losing streak Thursday night with a 4-3 victory over the Boston Bruins.

Michael Cammalleri scored on a penalty shot 1:04 into the game. Maxim Lapierre and Brian Gionta also scored and Carey Price stopped 34 shots for the Canadiens, who remained in first place in the division with 40 points.

“That’s a big game,” said Price, who got his league-leading 18th win. “Those games are obviously four-point games. We’re tied if they win that one — they actually move ahead of us — so that was one that we really needed.”

Boston’s Marc Savard had a goal and an assist, and Patrice Bergeron got his second assist of the game on Milan Lucic’s goal with 4:50 left in the third. Blake Wheeler also scored and Tim Thomas made 37 saves for the Bruins, who now trail the Canadiens by four points.

“We dug ourselves a hole again and tried to claw out of it, but it’s tough to continue to claw out of those holes each and every night,” Wheeler said.

Pacioretty, who made his season debut in Wednesday night’s loss to Philadelphia, put Montreal up 3-1 with his first goal in over a year with 30 seconds left in the first. Gomez got his first of two assists when Pacioretty’s backhander made its way in for his first goal since Nov. 25, 2009, ending a personal 28-game goal drought.

Pacioretty and Gomez both assisted on Gionta’s goal late in the second. Gionta, the Canadiens’ captain, got his 11th at 16:54 to give Montreal its third two-goal lead at 4-2.

Savard scored his first goal in seven games in the second and assisted on Bergeron’s power-play goal 15:10 into the third to draw Boston within one for the third time in the game.

Gomez had two assists for a second game in a row after missing Montreal’s two previous games because of a lower-body injury. He had nine points in 28 games before his injury.

Referee Bill McCreary awarded the penalty shot after Cammalleri was hooked by Bruins captain Zdeno Chara on a breakaway just over a minute in.

Thomas moved aggressively around the goal mouth as Cammalleri skated in on the penalty shot. Cammalleri deked and fired a shot over Thomas’ outstretched right pad for his 11th goal.

“I kind of looked up and saw him doing it and the first thought I had was, ‘Don’t change your shot because of him, just stick to what you want to do here and get him moving,’” Cammalleri said. “I think he was probably playing some mind games or something. Maybe next time I’ll snap it from center ice.”

Lapierre made it 2-0 with his fifth at 6:24 on a shot off the right post that went in off Thomas.

Wheeler cut the lead to 2-1 at 15:52 with a shot from the right edge of the goal mouth that trickled down Price’s pad and just made it across the goal line.

Canadiens defenseman P.K. Subban brought the crowd to life later in the period. The Montreal rookie backed into a solid open-ice hit on Brad Marchand, drawing the ire of several of the Bruins, including Gregory Campbell, who drew a roughing minor, the only penalty on the play.