Egypt scored a 95th-minute penalty to beat Congo 2-1 in Alexandria and so reach the World Cup for the first time in over a quarter of a century.
Mohamed Salah was the Egyptian hero, scoring both goals in a win that qualified them for their third finals – and first since 1990.
The euphoria was intense since Arnold Bouka-Moutou had stunned the hosts when equalising for Congo after 88 minutes.
But the Egyptians’ World Cup hoodoo ended as Salah held his nerve late on.
His dramatic winner sparked wild scenes of celebration both on and off the pitch, as several players and fans took to the field to celebrate while supporters wept with joy in the packed stands.
The Liverpool star had broken the deadlock just after the hour on a tense night in Alexandria as he latched on to Mohamed El Nenny’s pass before poking home from close range.
But an energised stadium was flattened just minutes from full time when Bouka-Moutou ghosted in at the far post to slam a volley home past Egypt goalkeeper Essam El Hadary.
Hopes were raised as five minutes of stoppage time were indicated and in the penultimate of these, Egypt were awarded a penalty.
Salah coolly sent the Congo keeper the wrong way to spark a night of celebrations across Egypt and end the record seven-time African champions’ poor World Cup record.
In the three decades since their last World Cup appearance, Egypt have won four Africa Cup of Nations titles – in 1998, 2006, 2008 and 2010 – but never taken that form into World Cup qualifying.
They had suffered repeated heart-break instead, with one of the most painful defeats coming in 2009 when losing a bitterly-contested play-off against Algeria.
The desperation to qualify ahead of the game was so great that Egypt’s Argentinian coach Hector Cuper admitted he was taking medication for high blood pressure.
The victory gives Egypt an unassailable four-point lead over Uganda in Group E, with one round of fixtures left, while
Ghana’s dreams are also ended.
The Egyptians become the second African team to reach the finals after Nigeria made it through on Saturday, with the continent’s remaining three places to be decided in November.
Should he play next year, Egypt goalkeeper El Hadary could become the oldest player at a World Cup ever.
The record was set by Colombian goalkeeper Faryd Mondragon, who played at the age of 43 at the 2014 World Cup, while El Hadary turns 45 next year.
Earlier this year, the North Africans – whose first World Cup appearance was way back in 1934 – finished runners-up in the Africa Cup of Nations.