Egypt advanced on Sunday to a semi-final showdown with the hosts Cameroon after a 2-1 win over Morocco in Yaoundé.
Morocco seized the initiative in the sixth minute at the Stade Ahmadou Ahidjo.
Sofiane Boufal converted a penalty after Ayman Ashraf felled Achraf Hakimi.
The deficit spurred Egypt who slowly began to exert control.
But Vahid Halilhodzic's men held on to their advantage comfortably in an increasingly scrappy game littered with misplaced passes and frequent fouls.
Energy
Egypt returned from the half-time pause intent on upping the pace and their intensity was rewarded in the 53rd mintue.
Morocco goalkeeper Yassine Bounou managed to beat away Mohamed Abdelmonem's header but the ball fell to an unmarked Mo Salah who tapped home gleefully.
It stayed 1-1 until full-time thanks largely to the Egypt goalkeeper Gabaski who pulled off a spectacular save to push Naif Aguerd's point- blank header onto the bar with nine minutes remaining.
He injured himself in the process but soldiered on until extra-time.
Soon after Gabaski's departure, Salah turned provider. Set free down the right wing, the Liverpool striker toyed with three Morocco defenders before pushing the ball across the penalty area for Trezeguet to slot past Bouno.
Egypt held on to their lead as Morocco - increasingly ragged and shorn of ideas - pushed wanly for an equaliser.