BARCELONA, Spain — An eye-popping goal by Ousmane Dembele and a superb performance by Barcelona's backup goalkeeper were minutes away from keeping Harry Kane's Tottenham out of the Champion League's last 16 on Tuesday.

But Kane provided the pass that substitute Lucas Moura used to finally score one past Jasper Cillessen in the 85th minute and secure a 1-1 draw that was as good as a victory to the English visitors and the few thousand fans that travelled with them to Spain.

Mauricio Pochettino's team will now look to improve on its round-of-16 exit last season, when it lost to Juventus 4-3 on aggregate. The draw for the knockout stage will be on Monday.

Barcelona rested Lionel Messi for the first hour, having already locked up first place before the match. The Spanish league leaders finished Group B with 14 points, while Tottenham secured second place by edging Inter Milan on its head-to-head record after both finished with eight points.

Inter was held to a 1-1 draw at home against PSV Eindhoven in the group's other match on Tuesday, sending the Italian side to the Europa League.

"We left it until late," said Kane. "Thankfully PSV got a draw for us, and a draw away to Barcelona is not a bad result."

Barcelona won its group for a record 20th time. With the draw, Barcelona also set a milestone after finishing its group unbeaten for a 12th time. It further matched Bayern Munich's streak of 29 Champions League unbeaten home matches that the German side established from 1998 to 2002.

With nothing at stake, Barcelona coach Ernesto Valverde rested Messi and regular starters Luis Suarez, Gerard Pique, Sergio Busquets, Jordi Alba, and Marc-Andre ter Stegen — and gave European debuts to youngsters Miranda and Carles Alena.

Dembele, who has clashed with his club for being late to practice at least twice this season, has earned applause on the field with his goals and playmaking in his second season at Camp Nou.

His goal against Tottenham was his best yet.

The 21-year-old France forward combined strength, speed and a fine finishing touch to turn a free kick by Tottenham into a superb seventh-minute opener for the hosts.

Dembele hustled to win the ball from Kyle Walker-Peters, one of two Tottenham defenders left near midfield to stop a possible Barcelona counterattack. Dembele then turned on the speed to go past Walker-Peters, before he cut back to his left foot to avoid a sliding Harry Winks and coolly fired in his eighth goal in all competitions this campaign.

But other than Dembele's great goal, the match was an onslaught by Tottenham that eventually proved too much for even the inspired Cillessen.

"You could see that we had less to play for than they did," Valverde said. "(Cillessen) is a top-rate goalkeeper. We are fortunate to have him. Every time he gets the chance to play, he impresses us."

The backup to Ter Stegen turned back shots by Son Heung-Min and Christian Eriksen before Barcelona's Philippe Coutinho almost doubled Barcelona's lead just before halftime when he hit the post.

Messi, who scored twice in a 4-2 win at Tottenham in October, came on in the 64th.

But Tottenham maintained the pressure and Cillessen blocked a shot by Eriksen before making his best save in the 76th when he palmed away a powerful, point-blank header by Moura just as it was about to cross the line.

Coutinho hit the woodwork again in the 83rd, but with Tottenham on the brink of finishing third behind Inter, Kane found Moura unmarked near the six-yard box to drill home a shot that Cillessen was helpless to turn away.

"I always believed that it was possible to win the game. We created a lot of chances and always had the game under control (and) in the end Lucas' goal arrived," Pochettino said.

"It's a massive, massive achievement for the club."

___

More AP soccer: https://apnews.com/apf-Soccer and https://twitter.com/AP_Sports