Josh Bailey #12 of the New York Islanders celebrates his...

Josh Bailey #12 of the New York Islanders celebrates his goal late during the third period against the New York Rangers with teammate Cal Clutterbuck #15 at Madison Square Garden on Thursday, Jan. 10, 2019 in New York City. Credit: Jim McIsaac

Superb individual performances are not enough for the Islanders, who have struggled in their team game of late.

So as good as Mathew Barzal was on Thursday night, the Islanders nearly cost themselves with a somnolent third period against the Rangers at Madison Square Garden. But on the Islanders’ only shot of the period (to the Rangers’ 17), Josh Bailey scored at 18:34 to give the Isles a 4-3 victory.

“It was pretty ugly on our part,” said Barzal, who had a goal and two assists and has four goals and 10 assists in seven career games against the Rangers. “We’ll take it any way we can get it, honestly.”

Robin Lehner made 27 saves and the Islanders (24-14-4) went 2-for-3 on the power play and killed off a 55-second five-on-three advantage for the Rangers (17-19-7) in the third period.

“We found a way,” Islanders coach Barry Trotz said. “To me, we won the game on special teams.”

The teams play again Saturday afternoon at Barclays Center. “It was a big win for us, but if we want to win the next game, we have a lot of things to fix,” said Lehner, who has won a career-high eight straight.

The Islanders, who had a season-high six-game winning streak snapped in Tuesday night’s 4-3 loss to the Hurricanes at NYCB Live’s Nassau Coliseum, have won 10 of 12. They are 13-2-0 against the Rangers — who have lost five straight — since Dec. 2, 2015.

Barzal delivered a responsible performance after his bad turnover led to a late first-period goal by the Hurricanes.

“That’s his job to produce and play good,” right wing Leo Komarov said. “Everyone has bad games. But he’s been playing really good all season.”

Barzal drew a holding call on Marc Staal at 1:38 of the second period and helped set up Anders Lee’s deflection of Nick Leddy’s power-play shot for a 3-2 lead at 3:08. Kevin Shattenkirk had tied the score at 2 at 1:11 of the second period.

With the Islanders up 3-2, Komarov was called for delay of game at 4:13 of the third period for knocking the Isles’ net off its moorings with defenseman Adam Pelech already in the penalty box for hooking. The Islanders held the Rangers without a shot on their five-on-three advantage, but Jesper Fast, swatting at a floating puck, tied the score at 3 at 8:40 of the period.

Trotz opted to put burly left wing Ross Johnston on Valtteri Filppula’s third line with Komarov, and Johnston immediately went after Cody McLeod, who missed three weeks after breaking his hand in a fight with Johnston in the second period of the Islanders’ 5-0 loss at the Garden on Nov. 21.

McLeod did not accept the invitation and Johnston wound up being called for unsportsmanlike conduct 17 seconds in when he flung off a glove.  Former Islander Ryan Strome made it 1-0 with a power-play goal at 1:38.

But Barzal, skating past Brett Howden on the right wing, got to the crease for a backhander past Henrik Lundqvist (16 saves) to tie it at 1 at 2:31.

Jordan Eberle’s power-play goal from the left circle, with Barzal getting the secondary assist, made it 2-1 at 8:51 of the first period.

Notes & quotes: Lehner is 3-2-2 against Lundqvist, a fellow Swede. The two first crossed paths in Gothenburg when Lundqvist, then 19, visited Lehner’s father, Michael, a goaltending coach . . . Rookie Michael Dal Colle was a healthy scratch for the first time in six games since being recalled from Bridgeport.

More Islanders