The Islanders’ latest loss to the Flyers was very fresh in their minds when it appeared they were headed for another one in the home-and-home rematch at the Coliseum.

Out of nowhere, the Islanders stormed back from a two-goal deficit in a dominant third period.

Kyle Okposo scored the tying goal on a power play late in regulation and then netted the decisive tally in the shootout for the Islanders, who rallied past Philadelphia 4-3 to earn a rare win over the Flyers.

Philadelphia came back in the third period at home on Saturday to beat the Islanders 6-4.

Okposo also assisted on captain John Tavares’ power-play goal in the second.

“We came up with good plays when we needed them most,” said Okposo, who has four goals and three assists in seven games since his daughter was born. “We wanted to come back after the game at Philly, and we did.”

Brock Nelson made it a one-goal game at 8:16 shortly after a power play, and Okposo tied it with 2:58 left on a lunging push with his stick after the puck struck his skate.

Frans Nielsen and Tavares also scored in the four-round shootout against Ray Emery, who made 40 saves through overtime.

“We were in a good position and had opportunities,” Emery said. “I didn’t stop the ones that I needed to stop. They gained momentum. We had them back on their heels, and they turned the tables.”

Anders Nilsson turned aside Vincent Lecavalier and Sean Couturier in the tiebreaker to help the Islanders avoid a four-game, season-series sweep. Philadelphia is 15-2-3 against New York since the start of the 2010-11 season.