SAN JOSE, Calif. — They managed to put a fresh, hellish twist on a terrible habit.

The Islanders rallied to tie Friday afternoon’s game against the Sharks on Nick Leddy’s goal with 57.2 seconds to play, pulling even with their net empty in the final minute after allowing three such goals against them this season.

Before the six attackers could catch their breath on the bench, however, the Islanders had given back the lead and the game. Patrick Marleau redirected Brent Burns’ point shot past Thomas Greiss with 22.5 seconds to go for a gut punch of a 3-2 loss that left an already reeling team speechless.

“Ummmm . . . No,” Cal Clutterbuck said when asked if he could explain what has happened to his team late in third periods this season. “Just mental errors in the last few minutes of games. I learned a long time ago as a pro that the first minute and the last minute of a period can win or lose you games. We’re losing a lot of them.”

This was the latest example of the team’s hideous trend of allowing game-tying or game-deciding goals in the final three minutes of regulation. The Islanders have allowed game-winning goals inside of three minutes remaining five times in 20 games, including the last two. Add in the three tying goals they’ve allowed in the final minute (1-0-2 in those games), and the lost points are dizzying in number.

“We probably played one of our best games, too,” said John Tavares, who outworked two Sharks along the boards, circled the net and found Leddy for a one-timer that tied the score. “We played a good game. We did a good job of taking it to them.”

advertisement | advertise on newsday

The Islanders led after a period on Anders Lee’s power-play deflection at 3:59, his third goal in two games. Greiss was sharp, denying Joe Thornton on a penalty shot later in the first and stopping 11 shots in the opening 20 minutes.

But two Sharks goals in 34 seconds reversed that in the second. Joe Pavelski scored off the rush at 5:09 and Burns’ 85-foot slapper hit off Calvin de Haan’s stick and knuckled past Greiss, putting the Islanders in a 2-1 hole after two periods.

For a team that’s been starved for offense, that hole seemed deeper than one goal. Tavares had shanked one with an open net in the second and, despite some better pressure in the third, the Islanders were not denting rookie goaltender Aaron Dell, who made 26 saves for his second NHL win — both against the Islanders.

Yet they managed to pull even before having a potential uplifting win — or at least a salvaged point — snatched away.

“There’s no explanation,” coach Jack Capuano said. “We have no puck luck right now. It’s nothing to do with anything . . . The hockey gods aren’t with us right now, and that’s a fact.”

On the Sharks’ winner, Pavelski won a battle behind the Islanders’ net and the puck worked around to Burns, who had room with Andrew Ladd marking him to pull the puck into a decent shooting position and get off a wrister intended for Marleau’s deflection as he cut through the slot.

It was reminiscent of the first time the Islanders lost in regulation after being tied in the final minutes — against these same Sharks on Oct. 18 at Barclays Center. Pavelski redirected Thornton’s shot/pass from high in the slot past Jaroslav Halak for a 3-2 defeat.

But on Friday, the Islanders were beaten in even more devastating fashion.

advertisement | advertise on newsday

“We have to win those battles,” Clutterbuck said. “We can’t let those plays happen.”