Morocco's Youssef En-Nesyri celebrates after he scored his side's second goal at the Al Thumama Stadium in Doha on Thursday. AP
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 on Thursday.
Canada's defeat meanwhile 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.
Morocco and Canadian fans during the World Cup Group F match at the Al Thumama Stadium in Doha. AFP
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.
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.
Morocco fans during the Qatar 2022 World Cup Group F match in Doha. AFP
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 setpiece 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.
Morocco's midfielder #07 Hakim Ziyech (front) celebrates with teammates after he scored his team's first goal. AFP
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.Earlier, Morocco coach Walid Regragui made two changes to his starting line-up and bring back goalkeeper Yassine Bounou following his absence from Sunday's win over Belgium in Group F.
He has also made an attacking change in midfield, with Abdelhamid Sabiri coming in for Selim Amallah.
Canada coach John Herdman has made four changes for his team's final game of the tournament following defeats to Belgium and Croatia.
Mark-Anthony Kaye comes into midfield for his first start of the tournament while Sam Adekugbe, Junior Hoilett and Jonathan Osorio have also been named in the starting line-up.
Canadian fans display signs inside the stadium before the match. Reuters
Bayern Munich star Alphonso Davies has been pushed into a more advanced role as Canada aim to thwart Morocco's qualification bid at the Al Thumama Stadium.
Morocco, who are second in Group F with four points, need only a draw to be assured of a place in the knockout rounds.
Milan Borjan; Alistair Johnston, Kamal Miller, Steven Vitoria; Sam Adekugbe, Mark-Anthony Kaye, Jonathan Osorio, Junior Hoilett; Alphonso Davies, Jonathan David, Tajon Buchanan
Coach: John Herdman (ENG)
Yassine Bounou; Achraf Hakimi, Nayef Aguerd, Romain Saiss (capt), Noussair Mazraoui; Sofyan Amrabat, Azzedine Ounahi, Abdelhamid Sabiri; Youssef En-Nesyri, Sofiane Boufal, Hakim Ziyech
Coach: Walid Regragui (MAR)
Referee: Raphael Claus (BRA)
Additionally, the forthcoming 2027 Asian Cup in Saudi Arabia and the potential bid for the 2034 World Cup by Qatar further emphasise the rapid evolution of infrastructure and the enduring passion for football in the Arab world.
The four-time World Cup winners came into the match needing a win but were also relying on the result of Japan's game with Spain to progress.
Spain also brought Barcelona's teen left-back Alejandro Balde in for his full international debut, while winger Nico Williams also starts, with Jordi Alba and Ferran Torres dropping out.
In a remarkable display of skill and determination, Faisal completed the fastest dive using an underwater wheelchair, clocking an astonishing time of 37 minutes and securing yet another spot in the sporting records.
"Test cricket throws different kinds of challenges, different kinds of pressures," Rohit told reporters. "But the way they have dealt with the pressures throughout the series has been superb."
Babar smashed 111 not out off 63 balls with 14 fours and two sixes and anchored Peshawar to 201-5. Yaqoob left Islamabad shell-shocked after taking four wickets in the penultimate over that included the key wicket of Munro.