Rangers center Filip Chytil reacts after scoring the game winning...

Rangers center Filip Chytil reacts after scoring the game winning goal during overtime of an NHL game against the Devils on Monday at Madison Square Garden. Credit: Mary Altaffer

Only a day earlier, Rangers coach Gerard Gallant had told reporters that he hoped he’d be able to keep the forward lines he had going for a while — give them time to mesh and find chemistry with one another and get rolling.

But with his team down two goals to the Devils less than five minutes into Monday night’s game at Madison Square Garden, Gallant just couldn’t stick with something he didn’t think was working.

So he changed his lines. And it worked.

“I’m tired of changing lines, I really am,’’ he said after the Rangers’ 4-3 overtime victory. “But you’ve got to do something when you’re a coach. And like I said, I want the lines to stay the same, but I didn’t like what I was seeing.’’

The Rangers (15-10-5) rallied from not one but two two-goal deficits to beat the Metropolitan Division-leading Devils (21-5-2) on Filip Chytil’s goal 2:15 into overtime. That extended their winning streak to four games.

“I think it’s one of our biggest wins, for sure, against a team like that,’’ center Vincent Trocheck said.

“They’ve been on fire all year. Whenever you have such confidence like they do, I mean, you win so many games, you gain a lot of confidence. You go up a couple goals, pretty much in your head, you’re thinking, ‘We have this game won.’

“To be able to come back against a team like that . . . definitely shows resilience in our team.’’

The turning point: Goaltender Igor Shesterkin stopped the Devils’ Jack Hughes on a penalty shot with 7:10 remaining in the second period.

The Devils had taken a 3-1 lead on a gorgeous goal by Hughes 1:45 earlier, at 11:05 of the period. After Hughes was tripped from behind by Braden Schneider, he could have put them up 4-1 if he had scored on the penalty shot. But Shesterkin managed to stay with Hughes through a series of dekes and got his stick on the puck before Hughes could shoot.

“I mean, that saves the game,’’ Rangers defenseman Adam Fox said. “If they go up three goals, it’s . . . obviously we can still come back, but it’s a lot bigger of a hill to climb. Instead, gives us a lot of momentum, we score two, and it’s a whole different game after that.’’

After Shesterkin kept it at 3-1, the Rangers got goals by Trocheck and Kaapo Kakko seven seconds apart to tie it at 3.

Trocheck tipped in a point shot by Fox on a power play at 13:58 of the second period. On the ensuing faceoff, K’Andre Miller sent a pass to Chytil down the left side and Chytil dropped a return pass to Miller, who swung it across the slot to Kakko, who one-timed it past Devils goalie Vitek Vanecek at 14:05.

Chytil then scored in overtime on a snipe in the top left corner against Vanecek after being set up by a pass from Artemi Panarin.

Goals by Nico Hischier and Dawson Mercer at 3:05 and 4:46 of the first period put the Rangers in a 2-0 hole. Chris Kreider finished a two-on-one pass by Trocheck to get the Rangers on the board at 18:25 of the period and give them life.

Miller was asked if finding a way to win, as the Rangers did, felt a little bit like last season, when they did this sort of thing routinely.

“Yeah,’’ he said. “I think we got to experience a little bit of that last year in finding games where maybe we weren’t supposed to win, or maybe we didn’t have all the bounces going our way, but we still found a way to stick with it and get those dirty wins, I guess.

“So I think we’re doing a great job of that right now on this little streak and finding what’s working and sticking with it.’’

SUBSCRIBE

Unlimited Digital AccessOnly 25¢for 6 months

ACT NOWSALE ENDS SOON | CANCEL ANYTIME