It felt like déjà vu for the Rangers.

They had again fallen behind the Panthers, whom the Rangers had already lost to twice this season.

In the third test between two of the NHL’s best, the Rangers quickly appeared on their way to another failure, down 2-0 and getting badly outplayed.

But that’s when star defenseman Adam Fox flipped the game on its head.

Adam Fox celebrates after he scored the Rangers' first goal in their win against the Panthers on Sunday.

Adam Fox celebrates after he scored the Rangers’ first goal in their win against the Panthers on Saturday. Jason Szenes for the NY Post

He drew a penalty, as Panthers forward Kyle Okposo was called for holding him, then on the power play worked his way down the slot before sniping in a wrist shot to cut the Rangers’ deficit to 2-1 6:22 into the second period of their 4-3 shootout win Saturday night at Madison Square Garden.

“You definitely saw us gain a little momentum,” Fox said about his goal. “When the crowd gets into it, we get some life. After that, it seemed like we started generating, we started playing in their end, causing some turnovers, and really got some life from it. You can always kind of sense when things aren’t going well, but that’s all it takes, something little like that. … I thought it was a good momentum swing there.”

It certainly was a momentum swing, as red-hot forward Artemi Panarin equalized just two minutes and one second later, sending Madison Square Garden into a frenzy.

From the verge of getting run out of their own building, the Rangers stormed right back into one of their most thrilling wins of the year.

It took just one play for the game to feel completely different.

“Down two goals, you need to have a spark,” forward Vincent Trocheck said of Fox’s goal. “You need to score that next one. To go down three would be a massive hole to climb out of against a team like that. So to get that next one, go down one, goes a long way. … That was a big one.”

Fox added an assist on Panarin’s goal, bringing him to 14 goals and 47 assists this season.

His 61 points are seventh-most among all defensemen in the league.

He’s been playing his best hockey when the Rangers have needed him most in recent weeks, recording 10 points — four goals and six assists — in his last seven games, a brutal stretch in which the Rangers have played many of the NHL’s elite in a short period of time.

Adam Fox has compiled 61 points this season, which sits seventh among NHL defensemen.

Adam Fox has compiled 61 points this season, which sits seventh among NHL defensemen. NHLI via Getty Images

Adam Fox's 14th goal of the season cut the Rangers' deficit to 2-1 against the Panthers on Saturday.

Adam Fox’s 14th goal of the season cut the Rangers’ deficit to 2-1 against the Panthers on Saturday. NHLI via Getty Images

Fox’s production has been critical, as the Rangers have been without defensemen Jacob Trouba and Ryan Lindgren, who are both battling lower-body injuries.

“[Fox is] so noticeable on the ice right now,” head coach Peter Laviolette said. “He’s playing at an elite level right now. But I think all of our defensemen are playing really well right now. To have a couple of guys out of the lineup, that we count on and are a big part of our [defense], guys step in there and fill those shoes, fill the voids for now, that’s really that next-man attitude.

Read the expert take on the Blueshirts

Sign up for Larry Brooks’ Inside the Rangers, a weekly Sports+ exclusive.

Thank you

“For me, what I see in [Fox’s] game is his attack inside the game, both defensively and most certainly offensively. The way he’s attacking the game is at a different level.”

The win brought the Rangers to 98 points — tied for most in the NHL with the Canucks — and put them in pole position for the Presidents’ Trophy.

It likely wouldn’t have been possible without Fox turning the tide.

“I think anytime a team beats us we wanna get our revenge and get a win against them,” Fox said. “They had two [wins] against us, they were both tight games, one-score games, no different [Saturday night], a tight game. They’re a good team, top of the league for a reason, so it was definitely a good effort. A big one.”

Additional reporting by Mollie Walker