South Africa suffered a major embarrassment on Sunday as a 2-0 defeat by Sudan in Khartoum saw the hosts clinch a place at the Africa Cup of Nations finals at the visitors' expense with first half goals from Saifeldin Maki and Mohamed Abdel Rahman.
Sudan qualified for only the third time in 23 attempts, finishing second in Group C behind Ghana, who won 3-1 at home to Sao Tome e Principe at the same time.
It was a major setback for South Africa, who needed at least draw but were defensively undone by their determined hosts.
Maki scored from a fifth minute set piece while Rahman's run down the left ended with an angled shot into the back of the net in the 31st minute.
Sudan are the 18th team to book a place at next January's finals in Cameroon, with the last six berths to be decided in the last round of qualifiers on Monday and Tuesday.
Ghana topped the group with 13 points after they beat the island minnows.
Nicholas Opoku scored first for Ghana followed, on the half hour, by Jordan Ayew. Baba Rahman made it 3-0 on the hour mark but Sao Tome pulled one back late through Jokceleny Carvalho, commonly known as Iniesta.
But after Seifeddine Jaziri had given them a fourth minute lead, Tunisia were guilty of poor finishing and only extended their advantage when Carlos Akapo turned the ball into his own net in the 52nd minute.
Tunisia substitute Firas Chaouat returned the favour two minutes from time to give the visitors a consolation goal.
Tanzania, who finished third in the group, condemned Libya to bottom place as Simon Msuva's goal just before halftime separated the two sides in their clash in Dar-es-Salaam.
Namibia, who were already eliminated, came from behind to beat already-qualified Guinea 2-1 in Windhoek with two headed goals from captain Peter Shalulile. Mamadou Kane had given Guinea an 18th minute lead in the Group A game.