Kovalchuk, who played four seasons for the Devils and helped them reach the Stanley Cup Final in 2012, was booed each time he touched the puck.
"I know they love me here," Kovalchuk said. "I actually had 3 1/2 great seasons here (2009-13), we went to the Final, so I have only great memories. It's always fun (to hear the fans); that's what brings people to the arena. Whether they are booing or cheering for you, this means you did something special."
[WATCH: All Canadiens vs. Devils highlights]
Joel Armia scored shorthanded to spark the Canadiens (25-23-7), who came back from down 3-0 with four straight goals.
"Me and Nate Thompson have good chemistry on the penalty kill, and know what we're doing," Armia said. "It's nice when you see those opportunities to do something special. I like the penalty kill; I like trying to shut down the other team's offense. It's all read and react."
Charlie Lindgren made 20 saves for Montreal, which has won three of its past four games but trails the Philadelphia Flyers by eight points for the second wild card into the Stanley Cup Playoffs from the Eastern Conference.
Christian Folin scored through a screen from the right point to give the Canadiens a 4-3 lead at 9:35 of the third period with his first goal of the season in his sixth game.
Kyle Palmieri scored his second power-play goal of the game with 20 seconds remaining to tie it 4-4. The Devils had a 6-on-4 advantage after the Canadiens were penalized for too many men on the ice at 18:51 of the third and they pulled goalie Louis Domingue for the extra attacker.
Video: MTL@NJD: Palmieri pots PPG from slot to tie game late
"[Blake Coleman, Wayne Simmonds, Jack Hughes and Nikita Gusev], everyone that was out there worked," Palmieri said. "It wasn't the prettiest goal, but we were delivering the puck to the net. Those guys that I just mentioned, they were grinding. I just happened to be right place, right time."
Jesper Bratt had a goal and an assist for New Jersey (18-24-10), which is 1-0-3 in its past four. Domingue made 32 saves.
Nick Cousins tied it 3-3 for Montreal at 7:22 of the third period when he scored on a quick shot from the slot off a centering pass from Brett Kulak.
Thompson got the Canadiens within 3-2 at 17:06 of the second when he skated around defenseman Will Butcher and scored with a wrist shot.
"Sometimes you have to keep it simple and do the right things or make plays north-south," Thompson said. "I think we weren't really doing that the first 10 minutes of the game, and it took us being down by three goals to wake up."
Armia scored off a neutral-zone turnover by Palmieri to make it 3-1 at 13:08 of the second.
Video: MTL@NJD: Armia roofs wrister in tight for SHG
Miles Wood gave New Jersey a 1-0 lead when he scored from the left face-off circle at 9:17 of the first period.
Palmieri made it 2-0 with a wrist shot from the right circle at 1:51 of the second after Shea Weber was called for tripping him at 1:46.
The Devils were 2-for-5 on the power play.
Bratt scored to give New Jersey a 3-0 lead at 6:44 of the second.
Video: MTL@NJD: Bratt sneaks shot home off missed shot
Since agreeing to a one-year, two-way contract with the Canadiens on Jan. 3 after being waived by the Los Angeles Kings on Dec. 16, Kovalchuk has 10 points (five goals, five assists) and is 2-for-2 in the shootout in 13 games.
"The most important thing is we won," he said. "The goalie (Domingue) was righty, so I didn't know what to do first, but then he took the glove away and gave me a little blocker, so I took it."
Lindgren made saves against Gusev, Palmieri and Hughes in the shootout.
They said it
"[Ilya Kovalchuk's] been a great influence in all aspects, from being a good example, his work ethic, his conditioning, his play, encouragement of others. He's been a real good addition." -- Canadiens coach Claude Julien
"The coach has given me the role I've always played, and I just try to do my best. It's been great chemistry between all the guys here. They have a lot of young guys with great talent, it's a great leadership group. I like everything here." -- Canadiens forward Ilya Kovalchuk
"We certainly have the knack for finding the overtime period. Tonight was one of those nights where it should not have gotten that far, in my opinion. We did have three guys come out of the lineup all at one time (forward Nico Hischier and defensemen P.K. Subban and Sami Vatanen), and that can be a big blow to a team, but guys stepped up and played their roles." -- Devils forward Blake Coleman
Need to know
Tomas Tatar had an assist on Folin's goal and has seven points (three goals, four assists) during a five-game point streak. ... Canadiens goalie Carey Price, defenseman Victor Mete and forward Jordan Weal each missed the game with flu-like symptoms. ... Subban did not play because of an illness, and Hischier and Vatanen each missed the game with a lower-body injury.
Canadiens: Host the Anaheim Ducks on Thursday (7 p.m. ET; TSN2, RDS, PRIME, NHL.TV)
Devils: At the Philadelphia Flyers on Thursday (7 p.m. ET; NBCSP, MSG+ 2, NHL.TV)
Video: Kovalchuk scores SO winner, Habs defeat Devils