EAST RUTHERFORD, N.J. — It was a storybook finish for the New York Rangers in their Stadium Series win over the New York Islanders on Sunday. But not necessarily the story they intended to tell.

“It wasn’t a script we would have written,” Rangers coach Peter Laviolette said after their 6-5 overtime victory in front of 79,690 fans at MetLife Stadium in the highest-scoring outdoor game in NHL history. “It was crazy. It was awesome. So many props to our guys after a first period that didn’t go the way we wanted at all.”

The Rangers took an early 1-0 lead but then watched the Islanders score three goals in 3 minutes, 14 seconds, including goals by Bo Horvat and Mathew Barzal 16 seconds apart. Just 1:03 into the second period, the Rangers were down 4-1. Even when they mounted a rally, the Islanders had an answer, and led 5-3 with five minutes left in regulation.

But at the final horn, the Rangers skated away with an incredible comeback win that was clinched by Artemi Panarin‘s unassisted goal just 10 seconds into overtime — scored with the net off its moorings. The goal was confirmed as valid after video review.

“I don’t remember that goal because I got flooded with a wave of emotions,” Panarin said through a translator. “But I’m 80 percent sure that it was a goal.”

According to ESPN rules analyst Dave Jackson, if the goal cage is dislodged by the defensive team, whether intentionally or accidentally, and there is an imminent scoring chance, as long as the puck passes between where the goalposts should be it counts. That was the case for Panarin.

“I’m sure the league and the refs got the right call in,” Islanders defenseman Noah Dobson said.

But other calls didn’t sit as well with the Islanders. The Rangers feasted on the Islanders’ last-ranked penalty kill with three power-play goals, including two in the third period with Igor Shesterkin pulled for an extra attacker. The Islanders penalty kill is now effective just 70.7% of the time.

“There were a couple of [calls] where we didn’t necessarily agree,” Islanders forward Brock Nelson said. “One kind of felt like a late call. Whatever it is, the ref makes up his mind. You got to go out there and get the job done.”

The Rangers got the job done despite a deficit, something this group has been known for this season. This was New York’s ninth third-period comeback win this season. That’s already the second most in franchise history, behind only the 11 comebacks in 2010-11.

“We take a look at ourselves and see what we have to do,” said Mika Zibanejad, who scored a third-period power-play goal, as did Chris Kreider. “In situations when we’re down, we know what we have to do and we’ve been pretty good at getting back on track and getting big goals, creating some sort of momentum to swing the game back our way.”

Laviolette praised his top players for fueling the rally, saying, “I thought our power-play guys at the end of the game, in the biggest of circumstances, really delivered.”

The win was the Rangers’ seventh in a row, moving them six points ahead of the Carolina Hurricanes for the Metropolitan Division lead. It was an important divisional game for the Rangers against their traditional rivals, but it also allowed them to look back fondly at the weekend’s events at MetLife Stadium, which included everything from a family skate on Friday to the team arriving in NYFD and NYPD jerseys before Sunday’s game.

“You still get two points for a win. But at the same time, you want to enjoy this weekend. And there’s no better way to finish this off than with a win like that,” Zibanejad said.