BOSTON — Defenseman Zdeno Chara broke a 2-2 tie with 12:53 left and the Bruins went on to a 4-2 victory over the New York Islanders Friday night.

Chara, who started his NHL career with the Islanders, took a pass from Milan Lucic and fired a 30-foot wrist shot past goalie Rick DiPietro for his first goal of the season.

Patrice Bergeron took a feed from Brad Marchand and scored on a breakaway with 6:27 left, with 19-year-old defenseman Dougie Hamilton starting the rush for his second assist of the game and third in the last two games.

Fourth-liners Shawn Thornton and Gregory Campbell also scored for the Bruins, who are undefeated in regulation play and 3-0-1.

Keith Aucoin, who hails from nearby Waltham, Mass., scored both goals for the Islanders (2-2-0). They were his second and third goals in two nights, giving his team the lead in the second period.

Tuukka Rask, who has taken over as the starting goalie spot with Tim Thomas deciding not to play the final year of his contract, again played well for Boston. He has played all four games at the start of this lockout-delayed season.

The oft-injured DiPietro, playing for the first time since Dec. 3, 2011 (groin surgery the latest of his many injuries), played well. But the local product (Winthrop, Mass. and Boston University) was beaten for the winner on a hard shot by Chara.

Chara hit the post with an open-net backhander in the final minute.

The Islanders, who rallied from behind to win in Toronto in their road opener Thursday night, rallied from a 1-0 deficit Friday, after Thornton, benched late in Wednesday night’s game in New York for a bad clear that led to a Ranger goal, opened the scoring by putting home the rebound of a shot by Hamilton 4:52 into the game.

As it turned out, the Bruins moved to 22-4 when tough guy Thornton scores.

Aucoin, a well-traveled veteran playing for his third NHL team, scored once in Toronto and scored his first goal Friday when Colin McDonald centered the puck out from behind the net for a bang-bang play at 11:13 of the first.

In the second period, Aucoin stepped into a loose puck at the top of the faceoff circle to Rask’s left (after Daniel Paille lost the puck in the corner) and blistered a slapper past Rask at the 9:50 mark.

The Bruins weren’t playing particularly well, but Campbell found himself in front of DiPietro, and he scored at 13:42. The game was tied 2-2 after two periods.

Hamilton, playing his fourth game of his six-game tryout with the Bruins, continues to play with poise and seems to be a sure bet to stay in the NHL. The fans chanted “Doug-ie, Doug-ie” for the kid in the third period.

Hamilton wears No. 27, the first number worn by Bruins great Bobby Orr, who was No. 27 in his first training camp before switching to No. 4.

NOTES: DiPietro has eight years left on the monster 15-year contract he signed in 2006, but could be a candidate to be bought out after this season as part of the amnesty buyouts that are part of the new collective bargaining agreement. … Defenseman Dennis Seidenberg, who missed two games with a lower body injury, was back in the Boston lineup, with Aaron Johnson a healthy scratch. … Bruins coach Claude Julien on the Islanders: “This is a young hockey team that has a lot of skill, obviously up front. Their back end also has some guys that can move the puck well; not only that, but can shoot the puck very well also. They’ve had some pretty good goaltending since the beginning.” … The Islanders were in the second game of a five-game trip that also includes the Winnipeg Jets, Pittsburgh Penguins and New Jersey Devils. The Bruins visit the Carolina Hurricanes Monday night and then host New Jersey Tuesday, their first back-to-back of this compact 48-game season. … The Islanders and Bruins came into the game as the only teams in the NHL that hadn’t surrendered a power play goal. … Both Aucoin and David Ullstrom, who assisted on Aucoin’s goal, have three-game point streaks.