First half goals from Saifeldin Maki and Mohamed Abdel Rahman ensured a 2-0 win for Sudan over COSAFA side South Africa in Khartoum on Sunday to seal a place at next the Africa Cup of Nations finals at their visitors' expense.
Sudan qualified for only the third time in 23 attempts, finishing second in Group C behind Ghana, who won 3-1 at home against Sao Tome e Principe at the same time.
It is a major disappointment for South Africa, who needed only a draw in the game but were defensively undone by their determined hosts.
Maki score from a fifth minute set-piece while Rahman's mazy run down the left ended with an angled shot into the back of the net in the 31st minute.
Sudan are the 18th side to book their place at next January's finals in Cameroon, with the last six more berths to be decided in the final round of qualifiers on Monday and Tuesday.
Ghana topped the group with 13 points as 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 Fernandes Carvalho, commonly known as Iniesta.
Earlier on Sunday, another COSAFA side, 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.
Tunisia finished their Group J campaign unbeaten, registering a fifth win in six games as they edged Equatorial Guinea 2-1 at home.
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.
But Tunisia substitute Firas Chaouat returned the favour two minutes from time as it ended in a 2-1 home win.
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.