Egypt beat Algeria to force play-off
Substitute Emad Moteab's header five minutes into stoppage time gave Egypt the winning margin they needed over Algeria in a tense encounter in front of just over 74,000 fans in the capital and ensured they finished level at the top of Group C.
FIFA determined earlier this week the two teams would play off in neutral Sudan if the group was deadlocked.
Algeria were a minute away from holding out for their first World Cup finals appearance in 24 years when Moteab struck with a looping header at the back post.
A 1-0 defeat would have seen Algeria through to the finals in South Africa on goal difference. Egypt needed to win by three clear goals to book a place for the first time since 1990.
The dramatic end replicated a furious start as Egypt took the lead after just two minutes through striker Amr Zaki.
He followed up after Mohamed Aboutrika struck the post and the initial rebound from Mohamed Zidan was palmed away Algeria goalkeeper Lounes Gaouaoui.
The match was preceded by an attack on the Algeria team bus by Egyptian youths in which three players suffered facial cuts. FIFA had to appeal for calm while the Egyptian FA claimed Thursday's incident was staged by the Algerians.