Youssef En-Nesyri celebrates scoring Morocco's second goal in the World Cup win against Canada that secured top spot in Group F / © AFP
Morocco powered into the last 16 of the World Cup for the first time in 36 years on Thursday with a 2-1 victory over eliminated Canada.
Goals from Hakim Ziyech and Youssef En-Nesyri ensured the North Africans finished top of Group F ahead of 2018 World Cup runners-up Croatia.
Morocco, who last reached the knockout stages of the World Cup in 1986, will face the runners-up from Group E in the last 16, with the identity of their opponents decided later Thursday.
"It wasn't easy, but when you have an opportunity to make history, you remember it," Morocco coach Walid Regragui said.
"We've made lots of people happy this evening, but let's not stop here.
"Before the tournament we set an objective -- we said we wanted to give everything we've got and get out of the group stages. We can tick that box now."
Canada's defeat capped a disappointing World Cup for the CONCACAF side, who depart after losing all three of their group games on their long-awaited return to the finals.
But coach John Herdman said his team would leave Qatar with heads held high.
"It's been the first time in a long time we've been here. We'd liked to have been longer but we've enjoyed the ride," Herdman said.
"Our players turned up here to compete. We've been fearless in each of the three games and in each of the three games we've had something to celebrate.
"This isn't Canada walking away with our heads down -- we leave with our heads held high."
Morocco put themselves firmly on course for the second round after upsetting Belgium 2-0 on Sunday, a result that left them needing only a point against Canada on Thursday to be sure of advancing.
- Borjan blunder -
Achieving that objective never looked in doubt after the Moroccans grabbed the lead after only four minutes in front of 43,102 fans at the Al-Thumama Stadium.
Canada captain and goalkeeper Milan Borjan raced off his line to clear an underhit backpass from Steven Vitoria but could only watch in horror as the ball fell to Morocco's Ziyech.
The Chelsea star seized the opportunity ruthlessly, coolly lifting a finish over the stranded Borjan into the empty net for 1-0.
That early setback winded Canada, who struggled to gain any sort of a foothold against a rampant Morocco who were soon 2-0 up.
Right-back Achraf Hakimi's long ball caught the Canadian defence napping and En-Nesyri darted in behind before smashing home a finish at the near post to beat Borjan.
Canada pulled a goal back on a rare foray forward five minutes from half-time when defender Sam Adekugbe skipped clear down the left and rifled in a low cross.
Defender Nayef Aguerd stuck a leg out and the ball deflected into the net past Morocco goalkeeper Yassine Bounou to make it 2-1.
Morocco thought they had restored their two-goal cushion in first-half stoppage time when En-Nesyri lashed home eight yards out only for the effort to be deemed offside.
Canada started the second half brightly, with Alphonso Davies jabbing a shot just wide after a promising attack.
But Morocco dropped deeper and Canada lacked the inventiveness to seriously threaten.
Their best chance of drawing level came from a set-piece on 71 minutes, when substitute Atiba Hutchinson's header from a corner crashed off the underside of the crossbar and bounced off the goal-line.
Full-back Alistair Johnston failed to control the rebound and Morocco's lead remained intact.
Canada captain Borjan almost got caught out again in another risky advance in injury time, but Davies was on hand to snuff out the danger before Morocco's raucous fans erupted in celebration at the whistle.