NEW YORK — The New York Islanders kept their composure after letting an early three-goal lead slip away late in the third period. They just went out and regained the advantage to pull out a big win against a charging division rival.

Ryan Pulock scored the tiebreaking goal with 41 seconds remaining and the Islanders recovered to beat the Philadelphia Flyers 5-3 Tuesday night.

The Flyers trailed 3-0 after 20 minutes, but scored twice in the second and then tied it on Sean Couturier's goal with 1:32 left on a carom off the end boards. Pulock came through with his big slap shot only 51 seconds later.

“You don’t want to see that, but we knew we had time,” Pulock said. “We had to regroup and get back on it and we went out and had a good shift.”

Josh Bailey, Jordan Eberle and Leo Komarov each had a goal and an assist, and Matt Martin also scored to help the Islanders win for the fifth time in eight games (5-1-2). Mathew Barzal had three assists.

“No matter how the game is going we’re staying with the process,” New York coach Barry Trotz said. “There’s no panic on our bench. We respond at the right times and tonight we did again.”

Semyon Varlamov stopped 35 shots as New York beat its Metropolitan Division rival for the third time in three meetings this season. The Islanders, splitting home games between the Nassau Coliseum and Barclays Center, improved to 7-0-3 in Brooklyn.

Travis Konecny and Robert Hagg also scored for the Flyers, who lost for just the fourth time in 12 games (8-3-1). Claude Giroux and Scott Laughton each had two assists, and Brian Elliott finished with 20 saves.

“It's frustrating,” Elliott said. "The guys battled back. I thought if we took it into overtime, we were going to win that one."

Komarov had an empty-netter in the closing seconds to seal the win.

The Islanders, third in the Metropolitan Division, pulled two points behind second-place Pittsburgh, which lost at home in overtime against Tampa Bay. New York also increased its lead to three points ahead of Philadelphia, which holds the Eastern Conference's second wild card.

“Getting it in regulation was huge," Islanders captain Anders Lee said. "There’s a lot of three-point games and you don’t want to see them within your division, for sure. That was a big extra win.”

After beating division-leading Washington 5-3 on Monday night, the Islanders trail the Capitals by just five points.

“This was a great two days for us," Lee added. “A couple of character wins in high-intensity games.”

Varlamov made 10 saves in the first period, 12 in the second and 13 in the third to win for just the second time in seven starts (2-4-1).

Varlamov gloved a shot by Philippe Myers on a rush at 5:44 of the second, preserving New York’s 3-0 lead and drawing chants of “Var-ly! Var-ly!’ from the crowd.

The Flyers then scored twice in 2:22 to get within one.

Konecny fired a shot from the left point that beat Varlamov for his team-leading 19th to pull Philadelphia to 3-1 at 9:34.

Hagg crashed the net and knocked in the rebound of Claude Giroux’s shot with just under eight minutes remaining in the middle period. It was the defenceman’s second of the season and first since Jan. 8 against Washington.

With the Islanders on the game’s first power play, Varlamov made a stellar stop on Michael Raffl’s short-handed try to preserve the lead with 3:42 left.

The Islanders scored three times in a 7:51 stretch of the first period to take the lead.

Bailey opened the scoring at 7:45 as he fired a one-timer off a pass from Barzal from the top of the left circle. The puck deflected off the stick of Philadelphia’s Tyler Pitlick and under the crossbar for Bailey’s 12th.

Martin made it 2-0 as he scored from the right side on a 2-on-1 rush with Leo Komarov with 8:47 left in the first. It was Martin’s fifth of the season and second in four games. Komarov got his 100th career assist on the play.

After some sustained pressure in the offensive zone, the Islanders added to their lead with 4:24 remaining in the opening period as Eberle knocked in the rebound of Barzal’s backhand for his 10th.

“We had a great start. ... We sort of let them back in the game and allowed them to do what they did,” Trotz said. “I thought we managed the third period pretty well. We knew they were going to be coming.”

NOTES: Islanders C Casey Cizikas left early in the first period with an apparent knee injury following a collision with Philadelphia’s Ivan Provorov. Cizikas did not return. ... Eberle has five goals and two assists in 19 games against Philadelphia. ... The Islanders won the first two meetings, 5-3 at Nassau Coliseum on Oct. 27, and 4-3 in a shootout at Philadelphia on Nov. 16. The teams conclude season series March 24 at Philadelphia. ... Giroux has 37 assists and 55 points in 52 games against the Islanders.

UP NEXT

Flyers: At Florida on Thursday night and Tampa Bay on Saturday to finish a three-game trip.

Islanders: At Nashville on Thursday night to open a four-game trip.

___

Follow Vin Cherwoo at www.twitter.com/VinCherwooAP

___

More AP NHL: www.apnews.com/NHL and www.twitter.com/AP_Sports