Matt Moulson, Tyler Ennis and Zemgus Girgensons all failed to beat Bernier.
Ryan Miller stopped Phil Kessel and James van Riemsdyk in the shootout. But Joffrey Lupul beat him on a nifty backhand.
Steve Ott had scored with 25 seconds left in regulation with the Leafs trying to kill off a six-on-four after Dion Phaneuf was called for hooking with 51 seconds remaining and Miller out of the Buffalo goal.
Ott, who had been flying in the third period, pounced on a Bernier rebound during a scramble and fired it into the net for his fifth of the season.
Jake Gardiner, Peter Holland and Kessel had scored second-period goals to put Toronto ahead 3-2 as the Leafs rallied from an ugly start.
It appeared that would be enough for only the Leafs' second regulation win in their last 19 outings (a 6-9-4 run). Toronto was coming off shootout losses to the Rangers and Red Wings and early on looked like it was headed for disaster against the league's worst team.
The Leafs fell behind 2-0 in the first period but owned Buffalo for almost all of the final 40 minutes. Outshot 15-10 in the first period, the Leafs roared back in the second when they outshot Buffalo 17-5.
Moulson and John Scott also scored for Buffalo as the NHL re-opened for business after the Christmas break.
For Scott, a six-foot-eight, 259-pound tough guy, the score ended a 164-game goal drought. But he was in the penalty box for the go-ahead goal in the second period by Kessel.
Both teams had chances in overtime with the Leafs dominating the final minutes. Miller made huge saves on both Van Riemsdyk and Phaneuf.
Bernier made 32 saves for the Leafs, who outshot Buffalo 42-35 in regulation time. Bernier was shaken up early in the third when Ott, diving after a puck, plowed into him but the goalie stayed in.
Miller deserved a better fate in the Buffalo goal.
The Sabres arrived on a mini-streak, having won three of their last four and gone 4-4-2 in their last 10 games. That included a 2-1 overtime win over Phoenix on Monday in a game where Buffalo was only able to dress 16 because of a flu bug.
Toronto was 3-5-2 over the same period.
Buffalo has been woeful on the road this season, compiling a 3-13-1 record. No one else has less than six wins away from home.
Toronto opened with some jump, outshooting the Sabres 6-2 with the second line of Lupul, Holland and Mason Raymond threatening. But Buffalo then ran off eight straight shots and two goals, with members of the Lupul-Holland-Raymond line on the ice for both of them.
The two goals were just 52 seconds apart, drawing loud boos from the crowd of 19,405.
Moulson scored the opening goal - something the Sabres have only done eight times this season - after Girgensons, coming out of the corner, fended off Holland like he was his kid brother. Girgensons then sent the puck to the crease where it appeared to hit Moulson and then Phaneuf. Moulson got credit for his 13th of the season at 7:01.
Things got uglier when the Leafs turned the puck over and Bernier misplayed the ensuing shoot-in on goal and shot. There were rebounds galore before the puck bounced back to Scott in the slot and the big man fired it into a gaping goal at 7:53.
Playing in his 200th career NHL game, Scott had doubled his goals total to two. Even Buffalo's official Twitter feed was taken aback.
``OH. MY. GOD! John Scott has given Buffalo a 2-0 lead!'' read the Sabres tweet.
Scott's only other goal was in November 2009.
The Leafs looked in disarray and coach Randy Carlyle couldn't get to the dressing room quick enough as the period ended to more boos.
Things changed in the second period with the Sabres back on their heels seemingly trying to protect a rare lead.
Toronto had an early power play but Miller hung tough in the face of prolonged pressure. Then the Leafs' top line of Kessel, Nazem Kadri and Van Riemsdyk began to turn the screw.
Gardiner finally beat Miller from the blue-line at 11:38 with Van Riemsdyk standing in front of goal and the Leafs dominating as if they had a man-advantage. It was Gardiner's second of the season.
Holland tied it up after Jamie McBain coughed the puck up in the Sabres corner and a falling Raymond managed to send it over to his centre, who beat Miller in-close for his sixth of the season at 16:25.
That led to a mocking chant of "Miller, Miller" from the crowd. In truth, the goalie was all that was keeping the Sabres together in the period.
A Scott penalty led a third Leaf goal from Kessel, who benefitted from a nifty pass from Van Riemsdyk after a howitzer from Phaneuf at the blue-line. Kessel's goal at 19:43 was his 18th of the season.
The ice continued to tilt in Toronto's favour in the third but it was slightly less so and the sandpaper-like Ott made things interesting by throwing himself into the fray.
Bernier had to be sharp a couple of times when the Leafs defence sagged late. And Moulson mistimed a puck that went flying through the crease.
Toronto defenceman Morgan Rielly hit the post at the other end seconds later.
Miller came into the game with an impressive 31-15-1 career record against the Leafs that featured a 2.44 goals-against average and .922 save percentage. Miller has more wins (31) and shutouts (4) against Toronto than any other team.
He had won both his previous starts against the Leafs this season, with a 1.49 goals-against average and .947 save percentage.
The Leafs have been all over the place this season, losing two of three to Buffalo prior to Friday while thumping Chicago - the league's best team at the time - by a 7-3 margin in mid-December.