Morocco advanced to the last 16 at the World Cup for just the second time after clinging on for a 2-1 win over Canada on Thursday.
The victory meant it finished top of Group F ahead of 2018 World Cup finalist Croatia and semifinalist Belgium.
Croatia went through in second and No. 2-ranked Belgium was surprisingly eliminated after their 0-0 draw.
The Moroccans' only other trip past the group stage came in 1986.
Hakim Ziyech scored for Morocco in the fourth minute after a bad error by Canada goalkeeper Milan Borjan left the winger to shoot the ball into an empty goal. Youssef En-Nesyri added a second in the 23rd.
It looked then like Morocco would overrun the Canadians.
But Nayef Aguerd's own-goal just before halftime made it 2-1 and lifted Canada enough for them to put pressure on Morocco in search of an equalizing goal for most of the second half.
Canada came agonizingly close when a header from captain Atiba Hutchinson, who came on as a second-half substitute, bounced off the crossbar and onto the goal-line, The Associated Press reported.
Canada, which will co-host the next World Cup in 2026 with the United States and Mexico, had already been eliminated before the Morocco game. It ultimately lost all three of its games in Qatar, matching its three defeats at its only other World Cup appearance in 1986.
The Moroccan squad players were already jumping up and down in a huddle near the dugout well before the final whistle and coach Walid Regragui was smiling broadly and gesturing with his arms for them to keep celebrating.
Morocco began its Qatar campaign with a morale-boosting draw against Croatia and then beat Belgium 2-0 for arguably its best result in international soccer.
Morocco has now won as many games at this World Cup as in all of its previous appearances at the tournament combined and is on course for its best performance at the tournament. The North African country’s only major international soccer title came at the 1976 African Cup of Nations.