Vincent Trocheck scored twice and had an assist, Panarin had a goal and two assists, and Shesterkin made 36 saves for the Rangers (36-16-3), who remained undefeated in outdoor games (5-0-0). Alexis Lafreniere and Adam Fox each had two assists.
"The first period, I thought we came in, we were a little sluggish and down on ourselves for the way we played," Trocheck said. "And then at 4-1 in that second period, I thought we were playing well. So, I don't think anybody had any ill feeling toward just the way that we're playing, and it was just a matter of us sticking with it. Showing some urgency and I think we did that."
Brock Nelson had a goal and an assist, and Dobson had three assists for the Islanders (22-18-14), who have lost three straight. Sorokin made 32 saves.
"Obviously when you have a 2-3 goal lead like we did, you have to find a way to get the two points and get the job done, and we just got to be a lot better," Dobson said.
After Erik Gustafsson gave the Rangers a 1-0 lead at 1:28 of the first period with a shot from the point that hit off Sorokin's shoulder and deflected into the net, the Islanders scored four straight goals.
Nelson tied it 1-1 at 4:20 with a shot from the right circle.
Horvat gave the Islanders a 2-1 lead at 7:18, skating past Rangers defenseman K'Andre Miller and scoring with a wrist shot from the right circle.
Barzal extended it to 3-1 on the power play 16 seconds later at 7:34, taking a pass from Nelson and deflecting the puck in while falling to the ice.
Anders Lee pushed it to 4-1 at 1:03 of the second period, tipping in a shot from Pierre Engvall on the power play.
"This was a massive game for us as a group and I thought we played a really good game,” Islanders forward Casey Cizikas said. “I thought we took it to them for 50-55 minutes and we just couldn't get it done in the end.”
Trocheck cut it to 4-2 with a power-play goal at 5:36, deflecting a shot by Panarin before making it 4-3 at 18:24, scoring off a rebound.
"We found ourselves in the box, weren't able to get the kills tonight against a really good power play," Lee said. "... Minus the way that game ended, it was a pretty great experience. Both sets of fans were great, the building was great, saw a great hockey game, but that's a sour ending for us."
Alexander Romanov gave the Islanders a 5-3 lead at 1:53 of the third, scoring off a rebound at the side of the net.
The Rangers became the first team to come back from a three-goal deficit to win an outdoor game.
"We got really good players, and a really good power play," Rangers captain Jacob Trouba said. "We were just as excited as everyone else in the place. As a team, that is a really fun game to play. … I think you have so many memories as a kid playing outside. ... That's such a dream. We're all little kids at heart."
It was the 18th comeback win of the season for the Rangers, tied for first in the NHL with the Dallas Stars and New Jersey Devils.
"Obviously it's a big goal by Panarin, but it was an unbelievable game," said Rangers coach Peter Laviolette, who won for the first time in five outdoor games coached (1-3-1). "When the game is coming down to it, and your best players on the ice get opportunities, power play, goalie pulled, and they needed to deliver to fight back in this game, and I just liked the resiliency."
NOTES: Rangers forward Matt Rempe became the first player in NHL history to make his debut in an outdoor game. He had a fighting major in 4:26 of ice time. … Nelson and Barzal's goals were the fastest two goals by one team in an NHL outdoor game. … … Dobson's second assist was his 50th of the season in his 54th game, trailing only Denis Potvin (53 games in 1978-79) for the fewest games in a season to reach 50 assists by an Islanders defenseman. … Rangers defenseman Ryan Lindgren left the game after one shift in the third period with an upper-body injury and did not return. Laviolette said he was still being evaluated.