Rangers defenseman Adam Fox celebrates his game winning goal against...

Rangers defenseman Adam Fox celebrates his game winning goal against the Stars with left wing Artemi Panarin and center Mika Zibanejad during overtime at Madison Square Garden on Thursday. Credit: Brad Penner

After rallying from two goals down on Tuesday to beat the Minnesota Wild at Madison Square Garden, the Rangers had every reason to believe that the one-goal deficit they faced at home Thursday was not insurmountable.

It wasn’t. But the Rangers used up nearly every second on the clock before pulling out their second straight comeback win.

K’Andre Miller’s buzzer-beater, which snaked its way through a maze of bodies and got past Stars goalie Jake Oettinger, tied the score with less than a second remaining in regulation.

Then, with all the momentum on their side, Adam Fox took a pass from Artemi Panarin and shoveled a backhander past Oettinger 1:16 into overtime to give the Rangers a thrilling 2-1 victory over Central Division-leading Dallas.

“We’re never going to quit,’’ coach Gerard Gallant said. “I mean, it’s a one-goal game, you battle hard, and you know you’re going to get a couple of looks late in it. And fortunately for us, we got lucky [inside] the blue line a couple of times. I can’t remember who kept the puck in [it was Miller], but it should have been out, and we kept it in and that led up to K’Andre’s goal. So you never quit. You keep battling hard . . . and fortunately for us, we had some traffic and found a way to get that goal.’’

The goal had to be reviewed to make sure the puck had crossed the goal line before time expired. Replays showed it crossed the line with nine-tenths of a second left.

Miller said he had no idea how little time was left when he scored. “No, no clue,’’ he said. “Obviously, the building gets going like that, everyone’s screaming, everyone’s excited. It’s awesome when the crowd gets that loud. I knew the time was winding down within the last minute there, so I just tried to get pucks on net, keep the puck in the zone.’’

With his top players all having been on for the final two minutes as they pressed for the tying goal, Gallant started youngsters Filip Chytil, Alexis Lafreniere and Braden Schneider in the three-on-three overtime. Chytil won the faceoff and the Rangers (24-12-7) controlled the puck until they were able to get a change and get Fox, Panarin and Mika Zibanejad on.

On the winning goal, Zibanejad and Panarin crashed the net with the puck and kept it alive until Panarin could get it over to Fox.

“Good job by Bread and Mika there, they were kind of battling,’’ Fox said. “I was hoping one of them would get it to me. Bread ended up finding me, and looked up, didn’t see much of the net. So figured I’d stop, put it to the backhand and then just put it to the far side, and it’s happy to see it go in for sure.’’

The win moved the Rangers (55 points) into a tie for second place with the Devils in the Metropolitan Division. They trail the first-place Hurricanes by four points.

Igor Shesterkin made 24 saves for the Rangers, who have won five of their last six games and are 13-2-2 since their Dec. 3 loss to Chicago.

Oettinger, who entered the game with the same amount of wins (19) as Shesterkin, finished with 29 saves.

With Chris Kreider out with an upper-body injury suffered Tuesday, the Rangers’ power play went scoreless in four chances.

Dallas converted its only opportunity in the second period, by Tyler Seguin at 17:53, to carry a lead into the third period.

Not a lot happened in the first period, other than a massive collision between the Rangers’ Julien Gauthier and Sammy Blais that led to Gauthier’s leaving the game with an upper-body injury.

The puck was in the Stars’ zone and Gauthier was skating out of the zone as Blais skated into it. The two players collided chest-to-chest at the outside edge of the right circle. Both went down heavily and stayed down.

After a moment, Blais was the first to get up. He skated, hunched over, off the ice with 1:20 remaining in the period.

Gauthier remained down on the ice for several moments, eventually getting up on one knee as he was attended to by athletic trainer Jim Ramsay. Then, after several minutes, he got to his feet and slowly skated off toward the dressing room.

SUBSCRIBE

Unlimited Digital AccessOnly 25¢for 6 months

ACT NOWSALE ENDS SOON | CANCEL ANYTIME