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.
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 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.
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.
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.