Mohamed Salah on Sunday scored the equaliser and created the winner for Egypt to come from behind to beat Morocco 2-1 at the Africa Cup of Nations (AFCON) in Cameroon.
Morocco went ahead in the seventh minute from a penalty kick converted by Sofiane Boufal in this quarter-final match.
But Egypt came storming back as they dominated the game at the Ahmadou Ahidjo Stadium in Yaoundé, with Salah scoring in the 53rd minute.
The Liverpool forward then turned provider to set up Mahmoud Trezeguet for the winner 10 minutes into extra time.
Egypt will now meet hosts Cameroon in a semi-final match in Yaounde on Thursday, after a much-improved performance following a slow start to the tournament.
Sunday’s victory kept Egypt on course to extend their record number of titles to eight.
But it also condemned Morocco to yet another failed campaign, having last made it to the semi-finals at the Cup of Nations in 2004.
They had made a strong start as marauding right-back Achraf Hakimi was brought down after five minutes by Ayman Ashraf.
A penalty kick was awarded after referee Maguette Ndiaye had consulted with the VAR.
But Egypt clawed their way back into the game as they began to dominate possession and Salah equalised.
This was when he pounced on a rebound, after Morocco goalkeeper Yassine Bounou had parried away a diving header from Mohamed Abdelmoneim.
Egypt continued to press for the winner, although Nayef Aguerd was inches away from restoring Morocco’s lead in the 81st-minute.
This was after he produced a powerful header from a free-kick which Egypt goalkeeper Mohamed Abougabal tipped onto the underside of the crossbar in a dramatic save.
Abougabal had come on for first-choice Mohamed El Shenawy in Egypt’s previous match but hurt himself making the save.
Although he tried to stay on, he was replaced in extra time by uncapped Mohamed Sobhi — Egypt’s third choice coming into the tournament.
Sobhi remained untested, however, by a tired Morocco team while Trezeguet then completed the turnaround in the 100th minute as he tapped in Salah’s pass at the back post.
“It was a great performance against a tough team that didn’t give us much,” said Salah.
“But we played well and managed to win and that’s the most important thing.”
Senegal play giant-killers Equatorial Guinea later at the same stadium in the last of the quarter-final clashes.