For the first time since 1986, an impassioned Moroccan team advanced to the last 16 of the World Cup after defeating the already-eliminated Canadians 2-1 on Thursday, mercilessly capitalizing on their opponents' blunders.
Morocco, who needed a win or a draw in their final Group F match to reach the knockout rounds, took advantage of a weak clearance by goalkeeper Milan Borjan that landed on the foot of Hakim Ziyech.
Cheered on by a boisterous crowd of Moroccan fans, midfielder Ziyech effortlessly lobbed the ball over the stranded goalkeeper to open the scoring in the fourth minute.
Borjan had been placed in an unenviable position by central defender Steven Vitoria, whose weak back pass forced the goalkeeper to race Moroccan forward Youssef En-Nesyri to the ball.
En-Nesyri remained dangerous throughout the first half, doubling Morocco's lead in the 23rd minute when he ran onto a long ball from Achraf Hakimi and beat Borjan at the near post.
En-Nesyri also thumped a volley into the Canadian net during stoppage time in the first half but that goal was ruled offside.
Overwhelmed with emotion, Hakimi wept after the match.
"I didn't think about it, but now I realize we made history," he said. "We work very hard and we deserve it."
With Croatia drawing with Belgium 0-0 in the other Group F game, Morocco finished first in the group and will face the second-place finishers in Group E, which comprises Japan, Spain, Germany and Costa Rica.
Moroccan manager Walid Regragui predicted his side will prove capable of challenging a mighty opponent in the knockout stage.
"We are going to be a very difficult team to beat," he said. "I think African teams can go far. Why shouldn't we dream of winning the World Cup?"
Moroccan defender Nayef Aguerd put Canada on the scoreboard with an own goal, the first of this World Cup, by accidentally flicking a cross by Sam Adekugbe past his own goalkeeper Yassine Bounou in the 40th minute.
Canada, who are exiting their first World Cup since 1986 without a point, automatically qualify for the 2026 tournament as co-hosts along with the United States and Mexico.