AFCON Qualifying Wrap: Holders Nigeria out
Stephen Keshi's Nigeria side, defending champions after their success in South Africa last year, failed to win any of their opening three Group A matches but gave themselves hope of a great escape by beating Sudan and Congo.
Those wins meant they were second ahead of their final game against South Africa, but a 2-2 draw saw them fail to reach the tournament proper for the first time since 2000.
Tokelo Rantie's double put South Africa in control, before Sone Aluko pulled one back in the 68th minute to offer hope to the home fans at the Akwa Ibom Stadium.
A red card for South Africa's Reneilwe Letsholonyane gave Nigeria further optimism and Aluko scored again in stoppage time, but it was too little too late.
South Africa, who have still yet to beat Nigeria in a competitive fixture, subsequently finish top of the group unbeaten, while Congo's 1-0 win at Sudan means they will also contest the tournament slated to start in Equatorial Guinea in January.
Egypt are also out after their chances of securing the qualifying spot for the best third-placed team were dashed when they surrendered a lead to lose 2-1 at Group G winners Tunisia.
With Tunisia and Senegal having already qualified, Egypt - the most successful team in AFCON history - needed to win by at least two clear goals to earn a reprieve but fell short.
Senegal rounded off their campaign with a 3-0 win at home to Botswana.
Egypt's failure meant that Democratic Republic of Congo take the vacant spot for the best of the rest after they defeated Sierra Leone 3-1 in Group D.
The Ivory Coast secured second spot in the pool after a 0-0 draw with group leaders Cameroon - who had Stephane Mbia sent off - but the game was marred by a mass pitch invasion, which saw fans and police clash.
Ghana booked their place courtesy of a 3-1 success at home to Togo in a close Group E, from which all four teams harboured hopes of qualifying.
The Black Stars' defeat to Uganda last Saturday meant they needed at least a point to qualify and Abdul Majeed Waris' first international goal in 13 months and a 35-yard rocket from Wakaso Mubarak put them 2-0 ahead by half-time.
Togo pulled one back shortly after the restart through Jonathan Ayite but Ghana's stand-in captain Emmanuel Agyemang-Badu made sure of the points in the 69th minute, meaning they finish top ahead of Guinea who beat Uganda 2-0.
In Group B Mali's 2-0 win over table-toppers Algeria saw them progress at the expense of Malawi who could only draw 0-0 with Ethiopia, while in Group C Gabon overtook Lesotho courtesy of a 4-2 win and Burkina Faso ended their successful campaign with a 1-1 draw against Angola, going through top.
Elsewhere, Cape Verde lost 1-0 at Zambia but both teams had qualified from Group F. The pool's other sides Niger and Mozambique drew 1-1.