The Bruins dominated the opening shift of the game, creating multiple scoring chances before Vatrano scored at 44 seconds. Detroit got a power play 1:16 later, but Bergeron forced a turnover and Marchand set up Brandon Carlo for a shorthanded goal to make it 2-0 at 2:27.
Vatrano scored his second of the game on the power play, giving the Bruins a 3-0 lead at 8:50. Mrazek replaced Jared Coreau after the goal.
Dylan Larkin scored to make it 3-1 at 15:32, but Bergeron made it 4-1 at 19:02 with a power-play goal.
Xavier Ouellet made it 4-2 at 4:21 of the second with his second goal of the season, and Andreas Athanasiou scored off Vanek's drop pass to pull the Red Wings within 4-3 at 9:54.
Tatar tied the game 4-4 at 14:36, scoring on a breakaway after Carlo fell down at the blue line, but the Bruins took a 5-4 lead 21 seconds later on Adam McQuaid's first goal in 70 games.
The Bruins held the one-goal lead for almost 22 minutes.
"I thought we did a good job after they tied it, but we had one more breakdown at the end, and they took advantage," Marchand said.