Mohamed Salah scored one goal and set up the other as Egypt beat Morocco in extra time in the Africa Cup of Nations quarter-finals.
Sofiane Boufal gave Morocco an early lead with a penalty after Ayman Ashraf caught Achraf Hakimi, a decision given by the video assistant referee.
But Salah tapped in an equaliser after Yassine Bounou parried a header and the game went to extra time.
Liverpool's Salah squared for Aston Villa's Trezeguet to tap in a winner.
Carlos Queiroz's side will face hosts Cameroon in Thursday's semi-final.
The seven-time champions may need to play that game with third-choice keeper Mohamed Sobhi, who came on for his international debut after Gabaski hurt himself while tipping Nayef Aguerd's header on to the bar near the end of normal time.
Without that save there would have been no semi-final to worry about - and Salah would have been on the next flight back to England.
Boufal's penalty was the only chance of note for either side in the first half - with most other efforts from long range.
Morocco were starting to dream of only their second semi-final since 1988 but Salah had other ideas, forcing extra time and then helping settle it by setting up half-time substitute Trezeguet.
Salah has been involved in 64% of Egypt's goals at the Africa Cup of Nations - nine of 14 - since he made his competition debut in 2017.
Egypt should have scored a third right at the end after Morocco keeper Bounou came up for a free-kick. Morocco played it short but Egypt made a mess of their counter-attack and Salah shot into the side-netting.
Latest Stories
-
Samson’s Take: Arrogance of Power, Shameful Policing
5 hours -
Burnley score late to draw with Manchester United at Old Trafford
8 hours -
Bayer Leverkusen extend unbeaten run to 46 games after draw with Stuttgart
8 hours -
Chelsea come from two goals down to draw against Aston Villa
8 hours -
Andre Ayew scores in Le Havre’s 3-3 draw with PSG
8 hours -
GPL 2023/24: Kotoko draw with Medeama; Samartex go 7 points clear of Nations FC
8 hours -
Mahama cuts sod for construction of new multipurpose Jakpa palace in Damongo
9 hours -
NSS management assists Papao fire victims
9 hours -
EXPLAINER: Will dumsor end soon?
10 hours -
IMANI Africa takes on EC, accuses it of lying and publishing half truths
11 hours -
Manasseh Azure calls for investigation and prosecution of those responsible for GRA/SML contract
11 hours -
Kwesi Atuahene: Ghana’s health capital depends on HealthTech – Africa Center for Digital Transformation
11 hours -
13 signs your wife is planning on leaving you and you have no idea
11 hours -
IMANI Africa: Ghana’s EC’s dangerous and pathological conduct
12 hours -
If I speak there will be fire – Salah on Klopp row
12 hours