A pair of quickfire first half goals fired Morocco to their first World Cup in two decades and condemned Ivory Coast to a defeat that means they will miss the showpiece event for the first time since 2002.
Morocco needed only a draw from their final Group C game to finish top of the standings in the African preliminaries, ahead of the Ivorians, who had to win to clinch a fourth successive World Cup finals appearance.
Morocco returns to the world's biggest stage for the first time since 1998.
Tunisia and Morocco completed CAF's line up at the FIFA World Cup™, securing the last of Africa's berths at Russian Federation 2018.
Tunisia also booked their spot at Russian Federation 2018 with a tense 0-0 draw against Libya.More news: Royals' Eric Hosmer named American League's 2017 Louisville Silver Slugger Award victor
More news: Taylor Swift's 'Reputation' Includes a Fiery Kanye West Feud Anthem
More news: TSA failing weapons tests by Homeland Security
Ivory Coast, meanwhile, failed to qualify for the quadrennial tournament after making it to the competition's finals for three times in a row in 2006, 2010 and 2014.
A goalless stalemate at home to Libya was enough for the Eagles of Carthage to pip Congo DR to top spot in Group A, while Morocco recorded an impressive 2-0 victory away to Côte d'Ivoire. But it was the Moroccans who got the breakthrough when Nabil Dirar's cross evaded everyone and found its way it to the net.
Dirar gave his side the lead in the 25 minute when a cross-cum-shot from the Fenerbahçe winger eluded Ivory Coast keeper Sylvain Gbohouo.
Morocco completed the campaign without conceding a goal, finishing on 12 points, four ahead of the Ivorians.
DR Congo defeated Guinea 3-1 but that did not matter as Tunisia had secured a point. Before today's matches, Tunisia had 13 points while DR Congo had 10 points.