Egypt made it through to the last 16 at the Africa Cup of Nations after drawing 2-2 with Cape Verde following a dramatic finale to Group B in Abidjan.
Egypt had looked set to finish third behind the Blue Sharks and Ghana before stoppage-time goals in both games.
Pharaohs forward Mostafa Mohamed netted what looked to be a 93rd-minute winner.
However, Cape Verde levelled six minutes later and the Pharaohs secured second spot as Ghana threw away a 2-0 lead in added time against Mozambique.
Rui Vitoria’s side will face the second-placed finisher in Group F in the last 16 on Sunday (20:00 GMT).
Egypt, with the injured Mohamed Salah watching on, trailed at the break through Benchimol’s smart finish but half-time substitute Trezeguet volleyed them level in the 50th minute.
The Pharaohs had known victory would be good enough to send them through in second place and, with Ghana leading Mozambique, they celebrated wildly after Mohamed lobbed Vozinha to put them 2-1 up in added time.
But drama followed after the Video Assistant Referee (VAR) sent match official Alhadi Mahamat to his pitchside monitor to rule whether Mohamed had controlled Trezeguet’s ball forward with his chest or hand.
The Chadian official eventually confirmed the goal, yet Egypt almost threw away all their hard work when Bryan Teixeira fired in from a narrow angle.
However, Ghana had somehow conspired to concede a 91st-minute penalty and a 94th-minute equaliser against Mozambique, which meant Egypt progressed to the knockout stages despite drawing all three group games in Ivory Coast.
Salah had been ruled out after being forced off during the 2-2 draw with Ghana last Thursday, but the forward was in the stands for what proved to be a nervy evening for the record seven-time continental champions.
The 31-year-old will return to Liverpool for treatment on his leg injury – and agent Ramy Abbas Issa has cast doubt on whether Salah will even be fit should Egypt reach the final on 11 February.
The Pharaohs trailed at the break despite bossing the first period, and Trezeguet epitomised their renewed purpose when he fired over straight after the restart.
After a smart one-two with Ahmed Hegazi the former Aston Villa man’s left-footed volley had enough power to go through Vozinha’s legs.
Trezeguet was at the heart of Egypt’s best openings, firing wide from range and forcing Vozinha to palm away a curling effort, and it was no surprise he unlocked the Cape Verde defence for Mohamed’s goal.
Cape Verde had already secured top spot in Group B before facing the North Africans and a much-changed side showed their mettle to equalise in the dying stages.
Some Pharaohs players sank to the turf in despair after Teixeira made it 2-2, assuming Ghana had claimed victory, yet the delay before the restart worked in their favour as they were informed a point was enough to progress.
Egypt were runners-up at the 2017 and 2021 finals and, after squeezing through to the knockout stages, still retain hope of Salah returning to clinch a first Afcon title since 2010.
Bbc