Islanders' Bo Horvat scores past Rangers goaltender Igor Shesterkin in...

Islanders' Bo Horvat scores past Rangers goaltender Igor Shesterkin in the first period at Madison Square Garden on Saturday. Credit: Kathleen Malone-Van Dyke

The Islanders were in desperate need of a reset against the Rangers on Saturday night at Madison Square Garden — a building in which they hadn’t won in three years — coming off a stale performance 24 hours earlier.

Coach Patrick Roy recognized the moment as his team started a seven-game road trip, reorganizing his defense pairs and his lines.

“Last game, we just weren’t happy with our game,” Bo Horvat said. “We came out and played the complete opposite tonight and played a great hockey game.”

It all worked in a 5-0 win, especially with Horvat continuing his torrid goal-scoring pace with two more — including one on the power play — to give him 11 in 15 games.

But none of the changes would have mattered if not for Ilya Sorokin’s stellar performance in the team’s first shutout this season. The Islanders, who had not won at the Garden since Nov. 8, 2022, are 2-0-1 in his last three starts. The No. 1 netminder is returning to his expected form with four goals allowed in that span.

“That was a good game,” Roy said. “I thought we were focused. I thought we played with some swagger. Ilya made some saves early and that kept us in the game and that brought a lot of confidence to the group. After that, we played a solid road game.”

Sorokin made 33 saves, and perhaps none was bigger than his acrobatic stop on Artemi Panarin on the doorstep 14 seconds into the game. He also denied Mika Zibanejad on back-to-back power-play chances from the low slot in the second period.

“Getting scored on in the first minute of a game after a game like [Friday], that’s not something you like,” said Jonathan Drouin, who had a goal and two assists. “So that was a huge save. He played so well. He was our best player tonight.”

“I just waited on his shot and thank God [Panarin] shot at my glove,” said Sorokin, who moved past Hall of Famer Billy Smith into second place on the franchise list with his 23rd shutout, two behind Chico Resch.

The Islanders (7-6-2) were coming off Friday night’s 5-2 loss to the Wild to conclude a 1-1-1 homestand at UBS Arena. In that game, the passes didn’t connect and the turnovers were frequent. Roy tried multiple combinations as he juggled his lines to no effect in the third period.

He knew he still had to search against the Rangers, so he split Horvat and Mathew Barzal on the top line, moving Barzal back to center and putting him between Drouin and Simon Holmstrom. Horvat centered Emil Heineman and Kyle Palmieri. Anthony Duclair was elevated to Jean-Gabriel Pageau’s third line with Anders Lee and fourth-line center Casey Cizikas worked with rookie Cal Ritchie — who had been centering the second line — and Max Tsyplakov, a healthy scratch the past four games.

Kyle MacLean became the odd forward out.

Defensively, Roy had No. 1 overall pick Matthew Schaefer with Ryan Pulock as his top pair. Pulock’s longtime partner, Adam Pelech, skated with Tony DeAngelo. Alexander Romanov was paired with Scott Mayfield, who had worked with Schaefer since the season opened.

The Romanov-DeAngelo pairing was a mess against the Wild, on the ice for both of their first-period goals.

“I don’t know if we were more aggressive [defensively], but I thought we were really solid,” Roy said. “We made some changes in our pairings and I thought everyone played really well. I’ve said many times, we’re going to try different things and we’re going to continue to try things. Tonight it did really work.”

Horvat opened the scoring at 10:29 of the first period off Heineman’s feed on the rush. Duclair, on the right wall, set up Drouin heading to the net with a saucer pass at 19:27 of the first period.

Drouin, inexplicably given ample time by the Rangers to operate off the right post on the Islanders’ first power play, finally dropped the puck to Horvat in the right circle for a 3-0 lead at 18:42 of the second period.

Sorokin made six saves with the Rangers skating six-on-five after pulling goalie Igor Shesterkin (21 saves) for an extra skater at 14:55 of the third period. Pageau scored an empty-netter at 17:59 and Lee closed the scoring with 29.9 seconds remaining.

SUBSCRIBE

Unlimited Digital AccessOnly 25¢for 6 months

ACT NOWSALE ENDS SOON | CANCEL ANYTIME