Egypt won after a penalty kick scored in the fifth minute of second half added time to reach the World Cup for the first time in over a quarter of a century.
Liverpool FC star Mohamed Salah was the Egyptian hero, scoring both goals in a win that qualified them for their third finals, and the 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.
Several players and fans took to the field to celebrate while supporters wept with joy in the packed stands.
Salah 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 kick.
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, and these were in 1998, 2006, 2008 and 2010.
But they have 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 they lost 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 also ended.
The Egyptians are now the second African team to reach the finals after Nigeria went through on Saturday, with the continent’s remaining three places to be decided in November.
Their qualification could be of great benefit to goalkeeper El Hadary who could become the oldest player at a World Cup ever if he plays next year.
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 — had finished runners-up at the Africa Cup of Nations.