From a Canadian point of view, there was a grim symmetry about Morocco's progress to the second phase of the 2022 World Cup.
The last time the North Africans achieved the feat came in 1986 - Canada's only appearance at the event.
In Mexico, Canada conceded five goals and failed to score in their three defeats.
Back among the elite, they again lost all their matches in the group stages but although they were breached on seven occasions over their three games, at least they will travel home with two goals to savour.
After Belgium and Croatia, Morocco were the lastest side to outwit John Herdman's team.
The 1-0 loss to Belgium in the opening game on 23 November seemed undeserved after a dominant display. Croatia proffered too much guile in the 4-1 humbling and on Thursday evening at the Al Thumama Stadium, Morocco suggested a polished version of Canada: poise, panache and precision.
Lead
Walid Regragui's side took the lead after four minutes.
Sousa Steven Vitoria's back pass to goalkeeper Milan Borjan was short and forced him out to clear as Youssef En-Nesyri charged in.
But Borjan's next touch was even more abysmal. Neither a pass to the nearby Kamal Miller nor a hoof upfield, it was a push forward and Hakim Ziyech deftly lobbed in his 19th goal for his country.
Midway through the half, Morocco doubled their lead. Achraf Hakimi received the ball just outside his penalty area, strode on a few metres and clipped it upfield for En-Nesyri who muscled in between Vitoria and Miller to thrash a shot past Borjan at his near post.
Comeback
Just as Morocco looked likely to swagger away, Canada pulled one back on the stroke of half-time through Nayef Aguerd's own-goal.
Revitalised, Canada came out and paid their opponents the ultimate compliment by copying them.
They hoarded possession in the 45-minute compact quest for their first point at a World Cup. Canada swashed. Morocco refused to buckle under the bombardments.
Borjan, attempting to atone for his earlier errors, raced upfield for a late corner - to no avail. The 35-year-old even pinged over a cross into the box.
Defence
The Morocco rearguard held firm and as the last few minutes of stoppage-time ticked away, the substitutes' bench started celebrating after news filtered through from the Ahmad Bin Ali Stadium that Croatia and Belgium had finished goalless - thus guaranteeing Morocco a place in the last-16 even if Canada were to level.
However, with the victory, Morocco advance as victors of Group F and will face the runners-up from Group E next Tuesday. Croatia will take on the Group E winners on Monday.