Updated

Patrice Bergeron scored the game-tying goal with 50.2 seconds left in regulation and then netted the game-winner 6:05 into overtime to cap a furious Boston comeback and send the Bruins into the Eastern Conference semifinals with a 5-4 win over the Toronto Maple Leafs in Game 7 of their quarterfinal set from TD Garden.

Boston trailed 4-1 over nine minutes into the third before scoring four unanswered goals to become the first team in NHL history to win a Game 7 when trailing by three goals in the final frame.

Nathan Horton and Milan Lucic each scored once in the rally before Bergeron fired a shot from the high slot that snuck through a screen and beat James Reimer up high to knot the game with under a minute left in regulation.

Bergeron then sent the Bruins into the second round just over six minutes into the extra session when his shot from the right circle was knocked down in front, but Toronto's clearing attempt ended up in the low right circle, where the Boston center retrieved it before finding the back of the net for the deciding goal.

"We made it interesting for us and for the fans," Bergeron said of his team falling behind by three goals. "We need to find a better way to do that but we showed a lot of character."

Matt Bartkowski also lit the lamp in regulation, while Tuukka Rask registered 24 saves for the Bruins, who will host the New York Rangers in the second round on Thursday after the Rangers won their Game 7 against Washington later on Monday.

Cody Franson scored twice, with Nazem Kadri and Phil Kessel each adding a goal and an assist for the Leafs, who were trying to overcome a 3-1 deficit to win a series for the first time since 1942 when they lost the first three games of the Stanley Cup Finals before storming back to beat Detroit.

Reimer posted 30 saves in defeat.

Toronto trailed 3-1 in the series before back-to-back 2-1 victories forced Monday's decisive Game 7.

The Leafs then put themselves in perfect position to complete their epic comeback after Kessel and Kadri scored a pair goals in a 3:20 span early in the third to stake Toronto to a seemingly comfortable 4-1 advantage.

But the Bruins put together one of the most improbably rallies to avoid blowing their third 3-1 series lead in franchise history.

Horton started the flurry at the 9:18 mark when he took a cross-ice feed from Lucic and blasted a one-timer from the left circle past Reimer to make it 4-2.

Still trailing by two with under two minutes left, Rask left the Boston net in favor of the extra attacker.

With a 6-on-5 advantage, Zdeno Chara fired a shot from the right point that Reimer knocked down, but Lucic was there to pound home the rebound to bring the Bruins within one with 1:22 left on the clock.

Bergeron forced overtime just 31 seconds later when he took a feed from David Krejci and rifled a shot through a bevy of bodies in front that Reimer never saw to knot the game at 4-4.

"I thought we just ran out of gas as a group," Maple Leafs coach Randy Carlyle admitted. "There's some people that really elevated their play [in the playoffs]. It does change your opinion on some individuals, and some other people, it reinforces what you thought."

Early on, Boston broke through just 5:39 in when a Franson turnover in the Toronto zone ended up on the stick of Bartkowski, who fired a heavy slapper past Reimer for a 1-0 lead.

Franson made up for the gaffe with his first of the game just under four minutes later when he stuffed in a rebound from the low right side at 9:35.

Franson then gave the Leafs the lead 5:48 into the second with a blast from the right point that beat Rask high to the far side for a 2-1 lead.

Kessel lit the lamp 2:09 into the third on a putback from the low left side before Kadri followed just under 3 1/2 minutes later when he buried a long rebound off a Kessel shot to make it 4-1 with 14:31 remaining in regulation.

Game Notes

This is the 14th time these Original Six teams have met in the playoffs, but the first since 1974, when Boston swept Toronto in the opening round. The teams last met in a Game 7 in the 1959 Stanley Cup semifinals when the Maple Leafs beat the Bruins by a 3-2 score ... Toronto fell to 12-10 in Game 7s, while Boston improved to 13-11 ... Toronto's last Game 7 was in 2004, when the Leafs beat Ottawa to win an opening-round series ... It was the first multi- goal game of Franson's career ... Boston led Montreal three games to one before losing the 2004 Eastern Conference quarterfinals and the B's held a 3-0 edge over Philadelphia in 2010 only to lose that second-round series ... Bartkowski's goal was the first of his career.