Morocco sealed its place in Russian Federation in style as they went to Abidjan and beat Cote d'Ivoire 2-0.
Morocco will make their first appearance at the global finals since France 1998, while Tunisia make their World Cup return for the first time since Germany 2006.
African champions Cameroon also secured a 2-2 draw away to Zambia in their inconsequential final Group B World Cup qualifier in Ndola thanks to a late goal from defender Yaya Banana.
As it stands, a total of 26 teams around the world have guaranteed their participation at next year's World Cup, as 6 teams from play-offs will complete the lineup by next week. It is the fifth time that the Moroccan national football team gets qualified for the global FIFA competition.
But it proved to be enough and, after missing out in 2010 and 2014, Tunisia will be at the World Cup for a fifth time. Morocco needed just a point from the game to qualify.
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.
With second-place Democratic Republic of Congo netting twice in stoppage time to defeat Guinea 3-1 in Kinshasa, only one point separated the top two. Benatia scored with a first-time shot from a corner five minutes later to seal the victory. Had Tunisia lost, the two teams would have finished level on points and goal difference and Congo would have taken the World Cup place for scoring more goals in the qualifying campaign.