Tuukka Rask stopped 24 shots for Boston, which led the best-of-seven series 3-1 before the Maple Leafs won two in a row to force a seventh game.
According to the Elias Sports Bureau, the Bruins are the first team in NHL history to win a Game 7 after trailing by three goals in the third period.
The Bruins will play the New York Rangers in the Eastern Conference semifinals. The Bruins will host Games 1 and 2 on Thursday and Sunday before traveling to New York for Games 3 and 4 on May 21 and 23.
Toronto opened a 4-1 lead in the third period of the decisive game, but Nathan Horton cut the deficit to two midway through the third period and then Lucic and Bergeron scored in the final 1:22 with Rask on the bench for an extra skater.
"Anything can happen," Lucic said, "and that's exactly what happened."
Cody Franson scored twice, and former Bruin Phil Kessel had a goal and an assist for Toronto. James Reimer made 30 saves for the Maple Leafs.
But it was the one he missed that left him sprawled in the crease, face down, while the Bruins celebrated.
"I was trying to be pretty even-keeled," said Reimer, who was teary-eyed in the locker room after the game. "There was time left, they could come back and they did. When you're up 4-1 you'd like to be able to hold onto that lead."
Rangers 5, Capitals 0 • Led by Henrik Lundqvist's 35 saves in a second consecutive shutout, and goals from some unlikely sources, New York beat host Washington in Game 7 to reach the Eastern Conference semifinals. New York contained Alex Ovechkin again and completed its comeback after trailing in the series 2-0 and 3-2 the latest in Washington's long history of playoff collapses.
Sixth-seeded New York faces No. 4 Boston in the second round.
It is the first time New York won a Game 7 on the road in its history.
Arron Asham put New York ahead in the first period, before Taylor Pyatt and Michael Del Zotto made it 3-0 early in the second on goals 2:10 apart.
Ryan Callahan added a goal 13 seconds into the third period, and when Mats Zuccarello scored with about 13½ minutes remaining, thousands of red-clad fans streamed to the exits.