David Pastrnak snapped a tie with 17.2 seconds left and the Boston Bruins beat the Chicago Blackhawks 4-3 on Thursday night for their eighth victory in 10 games.

Pastrnak finished with two goals and an assist. Jack Ahcan scored his first career goal, and Charlie Coyle also scored for the Bruins.

"It went our way tonight, but it got loose and could have went either way," Boston coach Bruce Cassidy said.

Cassidy wasn't pleased that the Bruins, coming off a 3-2 overtime loss to Los Angeles at home Tuesday night, got pushed to the brink of overtime by the Blackhawks, who aren't going to the playoffs and managed just three shots on goal in the second period. But Brandon Hagel's second goal of the night tied it at 3-all 3:24 into the third and set up a thrilling finish.

"It's a tough one, but we did a lot of good things," Chicago coach Derek King said. "It's unfortunate. It's just the way the puck went."

Hagel scored twice for Chicago, and Alex DeBrincat extended his streak to five straight games with a goal, giving him 34 for the season.

Patrick Kane got an assist for his eighth point in the last two games for the Blackhawks, who lost for the fourth time in six games and felt they let at least a point, perhaps two, slip away.

"They're a good hard-working team. We knew that coming into the game. We were expecting them to play hard," said Hagel, who got goals Nos. 19 and 20. "They were physical tonight and I thought we did a good job of not letting them just push us around like little kids. I thought we all battled together."

Chicago goalie Kevin Lankinen stopped 32 shots, including 18 in the third before a loose puck bounced to Pastrnak in front and he batted it in for his 33rd goal. The play came just after a faceoff, which Chicago won but Boston's Taylor Hall was able to dig a loose puck out of the corner and get it in front to Pastrnak.

"There was a couple breakdowns, but I think they're a really high skilled team, so a big win overall for us," Pastrnak said.

Jeremy Swayman had 22 saves for the Bruins.

Boston got a pair of power-play goals in the second while holding Chicago to just three shots on goal in the period. Ahcan, a rookie defenseman playing in just his eighth game, got his first NHL point when he scored a power-play goal on a wrist shot while backing across the slot at 11:57, tying it at 2.

"It was kind of crazy. I thought it hit the post and went wide. I didn't really see it," Ahcan said. "It's just such a great feeling. You do picture it over-and-over in your head before it actually happens and I don't think once it was like that, but it was a pretty awesome goal and nice to get it out of the way."

Boston jumped on the short-handed Blackhawks again after Connor Murphy was called for interference 14:31 into the second. Pastrnak scored on a one-timer from the left circle with six seconds left in the power-play opportunity.

Coyle put Boston up 1-0 when a rebound popped right to him at the left circle 4:12 into the game.

DeBrincat tied it at 1 when he fired a one-timer past Swayman off a crossing pass from Kane during a 4-on-1 rush with only Ahcan back for the Bruins.

Hagel then skated in alone on Swayman, circled behind the net and tucked a backhand in the far side to put the Blackhawks in front 4:12 into the second. Hagel picked up his 20th of the season 3:24 into the third when Swayman couldn't contain a rebound and the puck squirted out to Hagel alone in front of the crease during Chicago's third power play of the game.

"We had some good chances," King said. "Lanks made some huge saves there. It was a good game - a good game to watch. We just came out on the wrong end."

WORTH NOTING

Thursday was the first of two meetings between the Original Six clubs, with a rematch scheduled for Tuesday in Chicago. ... Chicago G Marc-Andre Fleury, who will be an unrestricted free agent after the season and a possibility to be moved by the March 21 trade deadline, did not play. ... DeBrincat entered the game sixth in the NHL with 33 goals, two ahead of Pastrnak.

UP NEXT

Blackhawks: At Ottawa on Saturday.

Bruins: Host Arizona on Saturday.