Brad Marchand and Trent Frederic also scored for Boston, and Charlie Coyle had two assists. Linus Ullmark had 25 saves in his 100th career win, improving to 24-2-1 on the season.
''I couldn't be more happy, its been overwhelming,'' Ullmark said of reaching his milestone. ''I have a lot of gratitude playing with the boys who work so hard every night.''
The Bruins (35-5-4) earned their third straight victory. The NHL's only 30-win team improved to 7-1-0 in 2023.
Zach Parise scored and Semyon Varlamov made 20 saves for the Islanders, who lost for the sixth time in seven games (1-4-2). They completed a season-high five-game homestand at 1-2-2.
''If you look back at all five games, I feel we played better than what the results are,'' Islanders coach Lane Lambert said. ''In these five games we've had plenty and ample opportunity. ... We're a little snake-bit right now.''
Bruins forward Patrice Bergeron briefly left the game after he was hit in the face by the puck on a slap shot from teammate David Pastrnak that deflected off the Islanders' Cal Clutterbuck at 4:26 of the third period.
Marchand then extended the Bruins' lead to 3-1 just 37 seconds later with a one-timer from the right faceoff dot off a pass from Pastrnak for his 15th.
''We're resilient, we're able to find another level,'' Marchand said after Boston improved to 24-0-1 when taking a lead into the third period. ''We have experience, the older guys know how to play.''
Parise hit a goalpost at 7:11, and Frederic sealed Boston's win when he tapped in a loose puck in front with 4:22 left for his 10th of the season.
''It's easy to say you can't get discouraged, but frustration is for sure high,'' Islanders forward Brock Nelson said. ''You just (have) to keep going, keep shooting. ... I've had looks where you'd like to have a different result.''
Trailing 1-0 after 20 minutes, the Bruins took the lead with two goals 4:12 apart midway through the second.
McAvoy tied it with a one-timer from the top of the left circle off a pass from Matt Grzelcyk for his third at 7:48.
''It was an important goal for us, got us back into it,'' McAvoy said. ''We were able to take over from there. ... Linus has been exceptional all season, he gives us a chance to win every night.''
Boston then took the lead after Varlamov stopped Pavel Zacha's initial shot from the point. However, as the puck trickled toward the goal line, Forbort skated in from the left side and poked it in before Varlamov could knock it away. It was his third.
Parise scored with 4:19 left in the first on a one-timer from the top of the left circle off a pass from Sebastian Aho. It was Parise's 13th goal of the season.
Jean-Gabriel Pageau had an assist on Parise's first-period goal, giving him five assists and eight points in his last 10 games. ... The Islanders finished 0 for 6 on the power play and fell to 3 for 51 over their last 18 games.
The Islanders gave out bobbleheads of Bob Nystrom, the bruising forward who spent 14 seasons with the franchise and was a member of the teams that won four straight Stanley Cup championships from 1980-83. Nystrom scored the winning goal in overtime of Game 6 of the 1980 Finals to give the Islanders their first title.
Bruins: At the Rangers on Thursday night to complete a two-game trip to New York.
Islanders: At Buffalo on Thursday night
Follow Vin Cherwoo at http://www.twitter.com/VinCherwooAP
AP NHL: https://apnews.com/hub/NHL and https://twitter.com/AP-Sports
Copyright 2023 STATS LLC and Associated Press. Any commercial use or distribution without the express written consent of STATS LLC and Associated Press is strictly prohibited.