Travis Sanheim also scored and Luká Sedlák added two assists for Philadelphia, which opened a five-game homestand by ending its third double-digit skid in less than 12 months.
"Are our problems solved? Absolutely not," Flyers coach John Tortorella said. "You get what you deserve, and I think we deserved to win tonight's game."
Noah Dobson scored for the Islanders, who had won four in a row.
"They played a good game," Dobson said. "We weren't as sharp as we needed to be."
The rebuilding Flyers won seven of their first 12 games under first-year coach Tortorella before the all-too-familiar slide.
Last season, the Flyers became the first team in NHL history to have a pair of 10-game losing streaks within the first 40 games of a season. They lost 10 straight from Nov. 18 to Dec. 8 before setting a franchise record with 13 consecutive defeats between Dec. 30 and Jan. 25. The first skid cost coach Alain Vigneault his job, the second one came with interim coach Mike Yeo in charge.
"It's no fun when you're losing every night," Hayes said.
Tortorella has been preaching effort, energy and hard work - and Philadelphia came out in this one looking like the Broad Street Bullies of the Flyers' glory days when they won their only Stanley Cups in 1974 and '75.
Philadelphia's Zack MacEwen and the Islanders' Matt Martin fought to a draw seven seconds into the game. One second later, the Flyers' Nick Deslauriers and New York's Ross Johnston dropped the gloves in another draw.
"That's part of hockey," Tortorella said. "We wanted a good start one way or the other."
The physicality and hitting stayed constant throughout.
Emotions were high not only because of the Flyers' losing streak, but also due to the fact the teams were playing the second game of a home-and-home, following Saturday's chippy 5-2 Islanders victory in New York.
Dobson gave the Islanders a 1-0 lead when he converted on a 5-on-3 power play with a slap shot 3:12 in.
Sanheim evened the score on a backhand from in close 1:25 later with a short-handed goal, and Hayes tied for the team lead with his seventh of the season to put Philadelphia ahead 2-1 by beating Ilya Sorokin on a hard wrist shot with 10:15 left in the first period.
"Sanheim's goal is so important just to get us settled down," Tortorella said. "I thought we were connected all night long in all three zones."
Hayes added an empty-netter with 33.2 seconds left.
Islanders: F Josh Bailey (upper body) is day-to-day after testing an injury in warmups and not being able to go. ... RW Kyle Palmieri remained sidelined with an upper-body injury for the fourth consecutive game. Palmieri didn't make the trip to Philadelphia and is day-to-day, coach Lane Lambert said. ... New York winger Cal Clutterbuck didn't return after leaving the ice late in the first period with an undisclosed injury.
Flyers: C Scott Laughton returned to the lineup after missing four games due to an upper-body injury. ... C Travis Konecny (upper body) missed his sixth game in a row, and D Tony DeAngelo (lower body) also was sidelined. ... RW Cam Atkinson could return Thursday against Tampa Bay after being out all season with an upper-body injury.
C Brock Nelson played in his 700th career game, all with the Islanders. He is the 10th player in club history to reach the milestone. ... Philadelphia entered with the worst power play in the league (14.3%) and went 0 for 2, dropping to 0 for 16 in the last six games.
Islanders: Host the Nashville Predators on Friday night.
Flyers: Host the Tampa Bay Lightning on Thursday night.
AP NHL: https://apnews.com/hub/nhl and https://twitter.com/AP--Sports