Noel Acciari had a goal and an assist, and Torey Krug had two assists for the Bruins, who got center Patrice Bergeron back after he missed Game 4 because of an upper-body injury.
The Bruins outshot the Maple Leafs 45-21 and out-attempted them 90-39.
"You've got to give their goaltender credit," Boston coach Bruce Cassidy said. "Both games we've lost we had over 40 shots on net, probably at least 20-something chances, not all on net, but we created chances. So he was very good tonight, let's face it. He made a lot of good saves. The ones we got weren't cheap."
Connor Brown gave the Maple Leafs a 1-0 lead at 6:36 of the first period when he batted the puck out of the air after Krug blocked Matthews' wraparound attempt.
Andreas Johnsson made it 2-0 at 10:12 with a backhand shot from the slot after a pass from Nazem Kadri through Bruins defensemen Zdeno Chara and Charlie McAvoy.
David Backes scored a power-play goal at 9:45 of the second period to cut the lead to 2-1, but Bozak scored 51 seconds later to give the Maple Leafs a 3-1 lead at 10:36.
Van Riemsdyk scored on the power play at 11:55 by stuffing in a pass from Mitchell Marner to give Toronto a 4-1 lead and chase Tuukka Rask, who allowed four goals on 13 shots. Anton Khudobin replaced Rask and made eight saves in his Stanley Cup Playoff debut.
"I didn't think [Rask] had it tonight," Cassidy said. "So we went with Anton, who's been very good for us. And then there's always that part that gets the rest of the team's attention as well. So it's both, I don't want to quantify what percentage was each. Clearly, if I thought he was on, then he wouldn't have got pulled. Let's put it that way."
Sean Kuraly scored with a one-timer from the slot off a backhand pass from the left face-off circle by defenseman Matt Grzelcyk to cut the lead to 4-2 at 17:18.
Acciari scored at 5:56 of the third to get Boston to within 4-3. After Krug's shot went wide, Tim Schaller played it off the back of the net to Acciari, who chipped it in before Andersen could get over.
"They were coming hard, they wanted to tie it up, and I think we might have been playing a little too much on our heels," Brown said. "It's important to keep going to get them and keep playing in their end. They were breaking out a little easier than we would have liked, but at the end of the day, we got a gutsy win down the stretch, and it's a real momentum-builder."