Pavel Zacha had a goal and two assists, and David Krejci and Mike Reilly each had a goal and an assist for the Bruins. Jeremy Swayman made 28 saves.
Mika Zibanejad and Kaapo Kakko each scored twice, and Jaroslav Halak made 21 saves for the Rangers.
Halak started in place of Igor Shesterkin, who was scheduled to play the entire game but sat out with a stomach issue.
Zibanejad gave New York a 1-0 lead 27 seconds into the first period when he scored from a sharp angle off Chris Kreider's pass across the crease.
Jake DeBrusk tied it 1-1 at 2:27 after getting to a loose puck near the top of the crease.
Zibanejad put the Rangers back in front 2-1 on the power play with a redirection in the slot at 18:08, and Kakko extended the lead to 3-1 on a breakaway with 45 seconds left.
Zacha cut it to 3-2 on a breakaway at 36 seconds of the second period after stealing the puck in the neutral zone.
Pastrnak tied it 3-3 at 8:09 on a one-timer from low in the left face-off circle, then fed Krejci for a go-ahead goal on the rush at 15:46.
Kakko tied it 4-4 at 6:49 of the third period when he knocked the puck across the goal line after Libor Hajek's shot trickled past Swayman.
Reilly scored at 12:10 with a shot from the right circle for the 5-4 final.
Capitals 4, Red Wings 2:Alex Ovechkin had his first goal and assist of the preseason to help the Washington Capitals to a 4-2 win against the Detroit Red Wings at Capital One Arena in Washington.
Ovechkin scored into an empty net with 54 seconds left in the third period. Connor Brown scored from the right circle at 17:33 of the third, 18 seconds into a power play to give the Capitals a 3-2 lead.
Darcy Kuemper made 31 saves for Washington.
Tyler Bertuzzi and Michael Rasmussen each had a goal and an assist for Detroit. Ville Husso made 31 saves.
Bertuzzi scored a power-play goal from the right side of the net at 8:09 of the first period to give the Red Wings a 1-0 lead. Connor McMichael scored from the slot on a pass from Ovechkin on a delayed penalty with 23 seconds left in the first to tie it 1-1.
Rasmussen scored on a 2-on-1 off a pass from Bertuzzi at 7:42 of the second period to give Detroit a 2-1 lead. Nick Jensen tied it 2-2 on a shot from the right point at 13:45.
Capitals forward T.J. Oshie left the game because of an upper-body injury with five minutes left in the second period after he was checked into the boards. He didn't practice Thursday and is day to day.