Tunisia finished on 14 points in Group A of the African preliminaries, one ahead of the Democratic Republic of Congo.
First half goals from Fenerbahçe right-back Nabil Dirar and Juventus centre-back Medhi Benatia helped Morocco beat Ivory Coast 2-0 on Saturday in a highly-temperamental Group C final World Cup qualifier in Abidjan and seal one of Africa's final two slots for next year's World Cup in Russian Federation.
Diving saves kept Youssef Msakni, Anice Badri and Ghilane Chaalani from scoring as Nashnush proved a one-man roadblock.
Marc Wilmots' Ivory Coast needed a win at home to qualify for their fourth consecutive World Cup, but two errors by goalkeeper Sylvain Gbohouo put chances of victory out of reach in the first half.
Libya avoided last place in the group with the draw as they advanced to four points with Guinea staying on three.
Libya had been forced to play all of their home games at neutral venues, including Tunisia, because of a Federation Internationale de Football Association ban on internationals in the country, where the security situation is judged unsafe for visiting teams.
The "Atlas Lions" are going back to the tournament for the first time since 1998.
In Mexico 1986, Morocco became the first African and Arab team to qualify to the second round of the World Cup after they came out as first in their group, which was comprised of England, Poland, and Portugal.
Tempers spilled over as the two sides exchanged wild tackles and punches in the closing stages and Ivorian fans pelted the pitch with objects as their frustration boiled over. While it scored eleven goals in six games, the national team did not concede a single goal. Gabon 0 drew with Mali 0.