Rangers players celebrate a goal by left wing Artemi Panarin...

Rangers players celebrate a goal by left wing Artemi Panarin against the Islanders in the second period of an NHL game at Madison Square Garden on Sunday. Credit: Kathleen Malone-Van Dyke

On paper, this first matchup of the season between the New York hockey rivals didn’t look like a fair fight. The Rangers, with forward Jimmy Vesey coming off long-term injured reserve and entering the lineup, finally had their best lineup available for the first time all season. The Islanders were missing two top-six forwards, including Mathew Barzal, and three of their top six defensemen.

But it was a familiar problem — special teams play — that cost the Islanders as opposed to a depleted lineup. The Rangers got a shorthanded goal and a power-play goal and then scored an empty-netter with more than three minutes left in a 5-2 win in Sunday’s matinee at the Garden.

Artemi Panarin had two goals — one on the power play and the second into the empty net with 3:22 left — and Igor Shesterkin had 35 saves for the Rangers (8-2-1).

Ilya Sorokin also had 35 saves for the Islanders (4-6-2), but the visitors failed to score on five power-play opportunities, allowed that shorthanded goal and gave up the one power-play goal in three chances.

“Special teams is such a big thing in this league, and they get a power-play goal and we don’t,’’ Islanders forward Bo Horvat said. “At the end of the day, it makes a difference every game.”

The Rangers had been outshot 87-37 in their previous two games. Coach Peter Laviolette had been so unhappy with their play — despite the fact that they won one of the two games — that he changed all of his forward lines and defense pairs for this game. The Rangers outshot the Islanders 40-37.

“I thought it was way better,’’ Laviolette said. “Goaltenders are gonna have to make big saves, both teams. That happens every single night. But the quality of the chances, I thought it was less. Did [Shesterkin] have to make some saves? Yeah. Was he good? Yeah, he was. But not like three of the last four games, where I just felt like it was just kind of one-sided.’’

Islanders coach Patrick Roy pointed to a save that Shesterkin made on Bo Horvat all alone in front to preserve a 3-2 lead 3:50 into the third period. A little less than 90 seconds later, Adam Edstrom’s redirection of a shot by Braden Schneider gave the Rangers a 4-2 lead at 5:18.

“We played a good game, well enough to win,’’ Roy said. “The play of that game is the save of their goalie on Horvat. If we score there, it would make it a 3-3 game and it gives us momentum.”

Rangers center Mika Zibanejad, who found himself playing between Panarin and Alexis Lafreniere — the team’s two top scorers — said all of the new lines looked good.

“I thought all the lines were jelling and playing well,’’ said Zibanejad, who had three assists. “I think that the good start that we got off to kind of got everyone’s energy up a little bit, and you’re excited to play with new guys, too.’’

The good start came courtesy of Zibanejad and longtime linemate Chris Kreider, who scored a shorthanded goal to give the Rangers the lead at 3:44 of the first period. Kreider and Zibanejad were on different lines at even strength, but they remained together as the first forward duo on the penalty kill.

The Rangers were killing a penalty to Jacob Trouba when Kreider managed to get the puck out of the zone, setting up a two-on-one with himself and Zibanejad. Kreider passed to Zibanejad, who passed it back, and Kreider banged it in for his seventh goal of the season.

“Nine years together, so you get familiar with each other, and obviously we play on the PK,’’ Zibanejad said. “He made a great play to me and just got open. I was ready for a pass back and I thought the lane was pretty open.”

Vincent Trocheck made it 2-0 at 1:21 of the second period on an even-strength goal set up by Reilly Smith, who stripped Samuel Bolduc, froze Sorokin with a fake and then dropped a pass to Trocheck in the slot.

The Islanders, without defensemen Adam Pelech, Alexander Romanov and Mike Reilly, plus Barzal and Anthony Duclair, got on the board when Casey Cizikas jammed in the rebound of Pierre Engvall’s shot for his first goal of the season at 4:38 of the period. Panarin’s power-play goal restored the Rangers’ two-goal lead at 11:04.

Brock Nelson banged in Kyle Palmieri’s pass with 8.0 seconds left in the second period to pull the Islanders within 3-2.