It was very nearly the worst loss in a season filled with awful losses.

But the Islanders pulled one out of the dumpster on Wednesday night when Anders Lee tipped home Thomas Hickey’s shot with 26.6 seconds to go, snapping a tie and sending the Isles to a 5-3 win over the Penguins in a game they led 3-0 entering the third.

Pittsburgh scored three times on Thomas Greiss in the final period, the last one from Evgeni Malkin with 6:52 left that could have left the Isles as shell-shocked as their fans were.

But Lee was alone in front of Matt Murray to tip home Hickey’s shot and Nikolay Kulemin hit the empty net three seconds later to give the Isles consecutive wins for the first time since the fifth and sixth games of the season.

“We were on our heels and that shouldn’t happen after the two periods we played,” said Johnny Boychuk, who opened the scoring on a slapper past Murray with 12.8 seconds left in the first and slid the puck to Hickey with the Penguins out of position on Lee’s winner. “But we kept going, we kept trying to do the right things and eventually the right thing happened.”

A win such as this has been long absent from the Isles’ repertoire. They played a spirited 40 minutes, jousting with the Penguins at every turn and getting a couple greasy goals in the second period to expand their lead.

advertisement | advertise on newsday

Jason Chimera had a rebound clank off his skate and Murray’s pad before crawling over the goal line at 2:10 of the second and Casey Cizikas roofed a puck that caromed from Bryan Rust’s face down to his stick at 17:21, a couple rewards for good effort that sent the Isles into the third with a 3-0 lead despite not scoring on a two-minute five on three in the middle frame.

“You keep doing the right things,” Jack Capuano said, “and you’re going to get rewarded. I’m proud of the effort.”

But the shakiness of this Isles team shone through from the very earliest stage of the third. Thomas Greiss, who made 22 saves through two, tried to sweep a loose puck away after a stop and it banked off Conor Sheary’s shin and in just 32 seconds into the third.

At 10:40 Justin Schultz walked down the left-wing boards after Chimera made a soft play to try and clear the puck and Schultz snapped one past Greiss.

And, at the end of a four-on-four segment, Evgeni Malkin finished off a give and go from Brian Dumoulin with an easy tap-in to tie it and bring the Penguins fans among the 12,149 at Barclays Center to life.

“We just have to keep playing the way we were,” Boychuk said. “Getting pucks in deep, getting on them, working the walls, getting good zone time. We were doing all that and then we stopped.”

But faced with the ominous closing minutes of the third period, where the Isles have lost five games this season inside of three minutes to go, they did not sit back. John Tavares stayed on past the end of his shift to hound the Penguins into a turnover deep, Boychuk drew Sheary to him and slid the puck to Hickey and Lee was alone in front for his fifth of the season.

It was immediately down to Washington for Thursday’s game with the Caps and a chance for the Isles’ first three-game win streak of the season.

“We got the win, which is great,” Chimera said. “But we can’t get the win that way.”