The win, coupled with Croatia's goalless tie with Belgium, saw Morocco top the group with seven points. Croatia finished second on five, while Belgium suffered a shock exit with Canada sitting bottom.
Morocco's coach Walid Regragui thought anything was possible for his side after winning the group.
"We said we wanted to give everything we've got and get through the group stage. Why not aim for the sky? We are not going to stop here," said Regragui.
Morocco collected four points after two rounds and a draw would be enough for them to book a berth in the next phase, while Canada had been eliminated following back-to-back defeats against Belgium and Croatia.
The Atlas Lions pressed high from the start, trying to use their aggression and tempo to good effect. It paid off just four minutes into the game when Canada defender Steven Vitoria's wayward pass forced goalkeeper Milan Borjan to clear the ball cheaply, and Morocco's Hakim Ziyech followed to send the ball into an empty net from distance.
Morocco doubled their lead in the 23rd minute when a long ball over the top found Youssef En Nesyri who outpaced two defenders to slot home.
The Canadians pulled one goal back in the 40th minute as Nayef Aguerd accidentally prodded Sam Adekugbe's pass into his net, scoring the first own goal of the Qatar World Cup.
En Nesyri thought he had scored his second before the break, but it was flagged offside.
Morocco were a little complacent and error-prone in the second half, allowing Canada to create a couple of chances. Atiba Hutchinson was close to scoring an equalizer but the veteran saw his header hit the goal-line after bouncing off the bar.
In a bid to avoid three consecutive defeats, Canada poured forward in the dying minutes and even Borjan rushed into the opposites' box, but they were still toothless to turn the game around.
Canada's coach John Herdman disclosed that they enjoyed the adventure despite an early elimination.
"It's been the first time in a long time we've been here. We'd like to have been here longer but we enjoyed the ride. We're a young team, we're developing, it's been a hell of an experience," he said.