Morocco qualified for the 2018 World Cup with a 2-0 victory away to Ivory Coast on Saturday.
The Ivorians thus miss out on a fourth consecutive appearance at the finals.
Goals from defenders Nabil Dirar and Medhi Benatia in Abidjan ensured that Morocco would finish as Group C winners.
Morocco needed only a draw in their last group game to finish top of the standings ahead of the Ivorians, who had to win to clinch a place in Russia.
After weathering an early storm, including a potential penalty call, Morocco scored two goals in the space of five minutes.
Dirar opened the scoring off a cross-turned-shot on 25 minutes and Benatia doubled the lead after a corner on the half-hour.
It is another achievement for Morocco’s French coach Herve Renard, who famously won the Africa Cup of Nations with Ivory Coast in 2015.
Morocco, who completed their qualifying campaign with maximum points and no goals conceded, last appeared in a World Cup in 1998 in France.
They topped the group on 12 points, four above the Ivorians. Gabon, who earlier drew 0-0 with Mali in Franceville, finished with seven and bottom-placed Mali five.