Sheldon Keefe feels his Maple Leafs have a long way go.

And that's a good thing.

Auston Matthews scored twice as Toronto dominated early before having to hang on late in Tuesday's 5-3 victory over the Buffalo Sabres.

The Leafs looked like schoolyard bullies playing keep away with the puck at times in the first period, but had just one goal to show for their efforts.

Toronto would lead 3-0 through 40 minutes, but warts were starting to show around the game's midway point. Buffalo pushed back and made it 4-3 late, and the Leafs needed a big penalty kill and an empty netter to finally seal it as Keefe improved to 8-4-0 since taking over for the fired Mike Babcock on Nov. 20.

"It just speaks to the potential of the team," Keefe said of his players picking up wins as they learn an entirely new system on the fly. "Because we're still nowhere near what I think we can look like and what we're capable of, but we're doing a lot of good things."

WATCH | Matthews leads Leafs past Sabres:

Auston Matthews scored two goals in the second period of Toronto's 5-3 win over Buffalo. 1:47

A perfect example of the difference between Keefe and Babcock came in the first when Leafs defencemen Morgan Rielly and Tyson Barrie were basically playing like rovers in the offensive zone, with the former setting up the latter for a great chance down low.

Barrie, who finished with two assists, said Keefe has encouraged that "a ton" since taking over a team that now wants to possess the puck as much as possible.

"He's actually showed clips where I'll dive in and end up in front of the net and he's like, 'I love that, do more of that,"' Barrie said. "I haven't had that often from a coach, so it's nice to see."

Frederik Gauthier, with a goal and an assist, Dmytro Timashov and Ilya Mikheyev provided the rest of the offence for Toronto (17-14-4), which got 27 saves from Frederik Andersen.

Toronto lore

Matthews, meanwhile, became the second player in franchise history to score at least 20 goals in each of his first four NHL seasons, joining Dave Keon, who did it in six straight from 1960-61 to 1965-66.

"It's pretty big honour just to be in the same breath as that guy," said the 22-year-old centre.

Rasmus Dahlin and Jack Eichel, with a goal and an assist each, and Kyle Okposo replied for Buffalo (16-12-7). NHL rookie scoring leader Victor Olofsson added two assists for the Sabres, who got 28 stops from Linus Ullmark.

Eichel extended his point streak to 17 games (16 goals, 15 assists) — the longest in the NHL this season.

"The battle level probably wasn't there," Buffalo's captain said of his team's start. "You've got to give them credit. They played well."

Toronto led 1-0 after that dominant first and went up 2-0 at 4:47 of the second when Matthews wired a shot under the crossbar shortside for his 20th.

The Leafs stretched their advantage to 3-0 with 2:21 left in the second when William Nylander found Matthews in the slot. He stepped around Conor Sheary like the Sabres forward wasn't even there before roofing a backhand past Ullmark.

The Sabres — who are now just a point up on their Atlantic Division rivals in the standings — made it 3-1 at 1:29 of the third when Dahlin buried his 10th on a power play.

Timashov restored the home side's three-goal lead at 4:58 when he scored his third on a backhand between Ullmark's pads following a breakaway feed from Barrie.

One last gasp

The visitors, however, were far from done.

Eichel beat Andersen on a tremendous shot for his 24th just 92 seconds later, and Okposo added his fourth to make it 4-3 with 5:19 left in regulation.

Buffalo got a power play shortly thereafter, but Mikheyev scored his sixth shorthanded into an empty net with 2:34 remaining with Ullmark on the bench for an extra attacker.

"Disappointed we didn't make more of a game of it early," Sabres head coach Ralph Krueger said. "When we made the push and we got to our game, we found our legs, there was a real chance."

The Leafs, meanwhile, still need to find a balance between going for it offensively and knowing when to pull back.

"You've got to be responsible," Barrie said. "There's got to be a line."

Toronto opened the scoring at 2:30 of the first when Gauthier pounced on a loose puck to snap home his fourth, and second in as many games, after sitting out four straight as a healthy scratch.

The Leafs, who were playing at home for the first time since Dec. 4 and coming off a 3-1-0 road trip, controlled the play for huge chunks of the period, but Ullmark was there each time before Matthews went to work in the second.

"Playing with the lead, getting the lead — a lot of good, positive things that we've seen," Keefe said. "Yet, I still think there's a long way for the team to go and continue to grow. "