Egpyt qualified for the last 16 of AFCON and rode out the tumult of one of the tournament's most dramatic group stage finales with a 2-2 draw against Cape Verde.
An injured Mo Salah watched from the stands as Egypt secured a point against the Group B winners to finish second in their group - with both sides scoring a goal in stoppage time.
A point would not have been enough without the late capitulation of Ghana, who conceded two stoppage-time goals to throw away a 2-0 lead against lowly Mozambique and only finish third in the group.
The results mean Egypt scrape into the last 16 with three points while Ghana are effectively out, having finished third in the group with two points.
Though Ghana could still qualify as one of the best four third-placed teams, their chances of doing so are devastatingly slender.
Salah - who has been slammed by the Egyptian public and their most-capped player ahead of returning to Liverpool for injury rehab - will be relieved that his country were spared their blushes.
He will have feared the worst with the Pharaohs staring at an early exit after falling behind to a goal from Gilson Tavares, while Ghana went ahead against Mozambique elsewhere.
But super sub Mahmoud Trezeguet hauled Egpyt level and Mostafa Mohamed fired them ahead at the start of stoppage time.
Cape Verde then rocked Egypt by equalising through Bryan Teixeira, but they were saved by Ghana's horror show.
Ghana, managed by former Brighton boss Chris Hughton, had taken a 2-0 lead against minnows Mozambique thanks to Jordan Ayew penalties either side of half-time.
But Mozambique pulled one back a minute into stoppage time when they were given a penalty after Ander Ayew - brother of their goalscorer - committed a handball and Geny Catamo
Read on m.allfootballapp.com