Toronto had come to Boston on a three-game losing streak, a streak that put them ahead of where they by all rights should have been this season, within striking distance of a playoff spot. They had dropped games to the Philadelphia Flyers, the Dallas Stars and the St. Louis Blues. But this one would be more important, a chance to gain ground on the team ahead of them in the Atlantic Division standings, a chance to deny their closest rival.

BOSTON -- It is remarkable how quickly these Toronto Maple Leafs can strike, how the young legs and the exceptional talent and the utter fearlessness combine to make opponents look, at times, foolish. It is remarkable how quickly they can give it all back, turning a game they had in hand into a question mark. It is remarkable, too, the resilience of a team that shouldn't have that resilience yet.

They did, finally, after all the back and forth and back on Saturday, after gaining a three-goal lead, losing it, breaking a tie, giving up a tying goal, and eventually getting a game-winner with 1:36 remaining.

"I've been in a number of these over the years, where your club doesn't win in a while, and it's usually ugly ones that find a way in," Maple Leafs coach Mike Babcock said. "So that was the ugly one and we appreciate a win."

All the madness ended deep into the third period, when James van Riemsdyk scored his second goal of the game at 18:24, giving the Maple Leafs the 6-5 win against the Boston Bruins. The two points put them one point behind the Bruins - with five games in hand.

Video: TOR@BOS: JVR nets late go-ahead goal through traffic

It is an enviable position to be in.

"It feels good," defenseman Morgan Rielly said. "We came in, we knew it was a big game. Not only in the standings, but we wanted to get back on the right track, get in the win column. It was a little bit of back-and-forth, I think a little more so than we would have liked, but we showed good resilience to come through and keep pushing."

This wasn't supposed to be the year for the Maple Leafs. It was too soon. They were too young. There were too many teams ahead of them. But the Tampa Bay Lightning have fallen off. The Florida Panthers got injured. Auston Matthews started his season by scoring four goals, and hasn't stopped since. The rest of the rookies became far more than rookies.

The Maple Leafs were making noise.

And then came a season-high three regulation losses in a row, a stretch that would threaten the confidence of any young team, and one that could have pushed the Maple Leafs into a spiral from which they might not have emerged.

But it didn't.

"In times like this you've got to stick together as a team," van Riemsdyk said. "I think we did that for the whole game. We played hard. We kept coming back when things didn't go our way. That was good."

It was a sign of maturation.

"That's obviously part of the process," van Riemsdyk said. "We've got a lot of firepower up front and there's going to be swings in the games. The good teams know how to handle adversity well. It was a good response game from us. Now we have to continue to play that way."

After David Pastrnak opened the scoring at 2:17 of the first period, William Nylander answered with the first of his three goals, at 11:15. He scored another at 9:09 of the second and one at 10:17 to complete the hat trick, with a van Riemsdyk goal in between at 8:31.

Video: TOR@BOS: Nylander notches hatty halfway through game

The Maple Leafs were up 4-1. That was, of course, the same score the Maple Leafs had been ahead of the Bruins in their 2013 Game 7 first-round matchup in the Stanley Cup Playoffs, the one that ended with Boston celebrating and Toronto in pain.

That was the last postseason game the Maple Leafs played.

But this one would not end the same way. Even though the Bruins came back, with Ryan Spooner tying the score 4-4 at 10:06 of the third, the Maple Leafs rallied twice. Connor Brown did it first, at 15:15, before Patrice Bergeron made it 5-5 at 17:06 on the power play.

It was van Riemsdyk's turn with less than two minutes to go, van Riemdyk's heroics that finally ended it. That came with a reminder that these are not the same Maple Leafs. The ending will not be the same for them. There is more talent. There is more of a future. There is a sense that, even when things are going wrong, they can save themselves. Not always, but more than could have been expected.

Van Riemsdyk is one of the few players left from 2013. The rest are too new. They don't know.

"That was a long time ago," van Riemsdyk said. "A lot of different players ago. We have new blood, a lot of new guys."

New hope, too.