Marchand put Boston ahead 1-0 at 5:02 of the first when he pulled a loose puck from below the goal line and lifted it near side over Binnington.
Hayes tied it 1-1 at 6:07 with a one-timer off a pass by Kasperi Kapanen from behind the net. He had a second goal overturned at 9:55 when the Bruins successfully challenged that he was offside prior to the goal.
McAvoy restored the Bruins' lead 2-1 at 6:26 of the second, shooting five-hole on Binnington after a St. Louis turnover.
Neighbours tied it 2-2 at 10:57 on the power play off a cross-crease pass by Jordan Kyrou.
Marchand's 5-on-3 power-play goal gave Boston a 3-2 lead at 7:43 of the third period.
Sundqvist made it 3-3 at 14:47 when he tipped a Scott Perunovich shot at the top of the crease on the power play.