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.