Islanders head coach Pete DeBoer looks on against the Toronto...

Islanders head coach Pete DeBoer looks on against the Toronto Maple Leafs in the first period of an NHL hockey game at UBS Arena on Thursday. Credit: Kathleen Malone-Van Dyke

The Islanders know they have no margin for error in this final week of the regular season if they are to emerge from the crowded field of Eastern Conference playoff contenders and make it to the postseason.

And so, in their first game under new coach Pete DeBoer — who replaced Patrick Roy on Sunday — they knew they absolutely could not afford to stub their toe against the sinking-like-a-stone Toronto Maple Leafs on Thursday night at UBS Arena.

This was a team that had fired general manager Brad Treliving on March 30, is without injured captain Auston Matthews, was playing on the second night of a back-to-back and had goalie Artur Akhtyamov making his first NHL start.

The Islanders took care of business, outshooting Toronto 44-16 and fashioning a gotta-have-it 5-3 victory, thanks in large part to another milestone by 18-year-old rookie sensation Matthew Schaefer. His goal midway through the second period broke a tie and propelled the Islanders to their first win since March 28, ending a four-game losing streak.

“There’s nothing that sells your coach’s message more than success, and having success and feeling that success within what you’re doing,’’ DeBoer said. “We got some of that tonight. Again, [there is still] a lot of work to do, but we took care of our business tonight, which was to win a game and stay relevant here in the playoff hunt. And we got to do it again Saturday.’’

The Islanders (43-31-5) have 91 points, moving them within one point of Philadelphia (40-27-12) — which lost to Detroit, 6-3 — for third place in the Metropolitan Division.

The Senators (42-27-10), whom the Islanders will face on Saturday, remained in the second wild-card spot in the Eastern Conference, improving to 94 points with their 5-1 win over Florida.

Schaefer scored his 23rd goal at 9:39 of the second period to put the Islanders in front 3-2 after they squandered an early 2-0 lead. He tied Brian Leetch for the most goals by a rookie defenseman in NHL history.

“You don’t really think about that stuff much, but obviously when it gets brought up, it’s crazy to think [about] and it’s definitely an honor,’’ said Schaefer, who gave the fans a scare when he briefly left the ice with 1:38 remaining after taking a shot high off his left shoulder before returning. “I don’t really worry about [records]. We’ve just got to worry about the games, and winning games.’’

Schaefer took a pass from Tony DeAngelo at the top of the left-wing circle, walked to the hash mark and whipped a shot into the small space between Akhtyamov’s pads to put the Islanders ahead to stay.

DeBoer, who scouted Schaefer extensively when he was an assistant coach for the Canadian Olympic team, was impressed.

“I told the coaching staff in there, they see him every night this year, so you probably get a little bit numb to it,’’ DeBoer said. “But for me, watching him from the bench live like that, it’s just, wow, what a player!’’

After Schaefer’s goal, the Islanders got power-play goals from Emil Heineman at 16:44 of the second period and Cal Ritchie at 10:20 of the third period to make it 5-2.

Morgan Rielly scored for Toronto at 14:04 of the third.

Playing against a Maple Leafs team that had lost to visiting Washington, 4-0, on Wednesday, the Islanders got an early scare when Easton Cowan’s harmless-looking shot bounced weirdly over goaltender Ilya Sorokin (13 saves) and was heading in before Schaefer pulled it off the goal line in the first minute of the game.

Brayden Schenn banged in a cross-crease pass from Ritchie at the back post on a delayed penalty to give the Islanders the lead at 2:08. Jean-Gabriel Pageau scored another back-post goal, banging in his own rebound at 4:55 to make it 2-0.

The Maple Leafs, who were being outshot 9-0 at that point, stunned the home crowd when Steven Lorentz scored from a sharp angle to get the visitors on the board 24 seconds later.

The period ended with the Islanders up 2-1 despite having compiled a 24-3 advantage in shots on goal.

It turned out to be not enough of a lead.

With the Islanders on a power play for the first 50 seconds of the second period, Ritchie was called for a high-sticking penalty, ending the power play early and ultimately giving the Leafs their first power play.

They cashed in when John Tavares set up Cowan for a goal that tied it at 2-2 at 1:57.

Horvat recognized. Before the game, Bo Horvat was presented the Bob Nystrom Award, which recognizes the Islanders player who exemplifies “leadership, hustle and dedication.’’

SUBSCRIBE

Unlimited Digital AccessOnly 25¢for 6 months

ACT NOWSALE ENDS SOON | CANCEL ANYTIME