(CNN) -- Egypt and Algeria will have to face each other again in a winner-takes-all World Cup playoff match after Emad Moteab scored a dramatic goal in the fifth minute of injury time to give the Pharaohs a 2-0 win in Cairo.
Amr Zaki had put Egypt ahead in the second minute in the Group Three clash but Algeria's defense stood firm and they looked set to progress to the tournament in South Africa as the clock ticked past the 90-minute mark.
But Moteab scored a sensational second goal which ensured the teams have identical qualifying records and will have to play again in a special one-off match in Sudan on Wednesday.
In Group Two, Obafemi Martins struck twice to help Nigeria record a 3-2 victory over Kenya in Nairobi and clinch their place at the finals.
Dennis Oliech had given Kenya the lead at half-time after his opened the scoring in the 16th minute but Wolfsburg striker Martins helped the 'Super Eagles' hit back as he equalized in the 62nd minute.
Everton forward Aiyegbeni Yakubu put Nigeria ahead but Nigeria's were pegged back in the 78th minute when Allan Watende punished some poor defending.
But Martins hit the winner in the 83rd minute when he swiveled and struck his shot past Kenya goalkeeper Willis Ochieng and into the net.
Nigeria only secured their fourth appearance at the finals after they leapfrogged Tunisia -- who slipped to a 1-0 defeat to Mozambique -- to finish a point ahead of them at the top of Group Two.
Dario Monteiro was the hero for Mozambique when he grabbed the winner in Maputo in the 83rd minute after he beat the offside trap and slammed the ball home from the edge of the penalty area.
Paul Le Guen's Cameroon booked their place with a 2-0 win over Morocco in Group One while Gabon's dreams of qualification ended with a 1-0 defeat in Togo.
Achille Webo and Samuel Eto were both on the scoresheet for the 'Indomitable Lions' who will set a new African record of six World Cup appearances in South Africa.
Webo opened the scoring for Cameroon in Fez in the 18th minute when his left-footed shot cannoned into the net off the post.
Inter Milan striker Eto'o effectively made the result safe in the 52nd minute when he headed home Geremi's corner as Cameroon finished top of the group.
Gabon's slim hopes of qualifying were dependent on Cameroon slipping up but ultimately their campaign ended in defeat to Togo.
Lome Floyd Ayite struck in the dying moments which rubberstamped Togo's place at the African Nations Cup in Angola.
Sudan's woeful run continued as they slipped to 2-1 home defeat to Benin and ended their Group Four campaign with just one point.
A Razak Omotoyossi penalty gave Benin the lead before Mudathir El Tahir also converted from the spot but Romuald Boco gave the visitors the points.
In Group Five, Ivory Coast ended their campaign unbeaten after they cruised to a 3-0 victory over Guinea in Abidjan thanks to two goals from Gervinho and one from Siaka Tiene.
Malawi qualified for only their second ever African Nations Cup despite a 1-0 defeat to Burkina Faso with Moumouni Dagano on target in Ouagadougou.