The Boston Bruins celebrate after David Pastrnak scored in overtime against the Dallas Stars on Tuesday night in Dallas. Tony Gutierrez/Associated Press

DALLAS — David Pastrnak scored with 1:16 remaining in overtime, and the Boston Bruins rallied for a 3-2 victory over the Dallas Stars on Tuesday night in a matchup of the top teams in each conference.

Pavel Zacha scored the tying goal in the third period for the NHL-leading Bruins in Jim Montgomery’s first game as a head coach in Dallas since the Stars fired him in 2019 for what he later admitted was a drinking problem.

The Stars couldn’t convert on 57 seconds of a 5-on-3 power play in the second period and a two-minute 4-on-3 session in the extra period. They finished 3-1-4 on an eight-game homestand that featured five games going to extra time, including four in a row.

Western Conference-leading Dallas finished the long homestand with consecutive losses to East contenders. The first was a 3-1 loss to three-time defending East champion Tampa Bay when the Lightning scored the go-ahead goal in the final minute.

Taylor Hall opened the scoring for Boston, and Jason Robertson had his team-leading 34th to give Dallas a 2-1 lead in the second period. Joe Pavelski had two assists for Dallas.

Pastrnak, who assisted on Zacha’s tying goal, scored his team-leading 39th with the teams playing 4-on-4 in overtime because play never stopped after Brad Marchand’s interference penalty ended 2 1/2 minutes into the extra period.