Morocco ended their two-decade wait for a World Cup ticket by beating Ivory Coast 2-0 in Abidjan on Saturday to secure top spot in Group C.
The Atlas Lions just needed to avoid defeat in order to book their place in Russia, but took all three points after Nabil Dirar and Medhi Benatia struck twice in the space of five first-half minutes to heap further misery on under-pressure Elephants coach Marc Wilmots.
The result took them up to 12 points, four clear of the Ivorians in second place, confirming their return to the World Cup for the first time since 1998, when they were eliminated in the group stage.
Gabon and Mali finish third and fourth in Group C - on six and four points respectively - after playing out a 0-0 draw in Franceville earlier on Saturday.
Ivory Coast have struggled for consistency during the qualifying campaign, and have wholly failed to shake off the malaise that followed their dismal Nations Cup title defence in Gabon earlier this year.
They were nervy from the off in Saturday's decisive clash, where they knew that only a win against former coach Herve Renard - the man who masterminded their AFCON success in 2015 - would be enough to pip the Atlas Lions into top spot.
Any hopes they had of overhauling the North Africans were all but extinguished in five minutes of first-half madness from goalkeeper Sylvain Gbohouo, who struggled behind an unfamiliar defensive pairing of Simon Deli and Jean-Philippe Gbamin.
In the 25th minute, the stopper was beaten by Dirar's tame left-footed cross from the right flank, as the ball failed to meet the diving Khalid Boutaib, but still evaded Gbohouo before nestling in the far corner.
Five minutes later, perhaps still shaken by his error for the first goal, he hesitated after deciding to come for a corner, and was left in no man's land when Benatia prodded home into the roof of the net.
The individual efforts of Gervinho, Wilfried Zaha and Serge Aurier failed to find a way past Morocco's defence - marshalled by the excellent Benatia - during the second half, while Wilmots introduced Maxwel Cornet and Ghislain Konan to scant effect.
Aurier had the best chance to hand the Elephants an undeserved lifeline just after the hour mark, but he could only blaze over from inside the area after being picked out by Zaha's cutback.
While the Elephants will be left to rue a first World Cup qualifying failure since 2002, Morocco can now look forward to heading to Russia as North Africa's third representatives alongside Tunisia and Egypt.