Sofiane Boufal celebrates after giving Morocco an early lead from a penalty in an Africa Cup of Nations quarter-final against Egypt in Yaounde on Sunday.
Mohamed Salah inspired Egypt to a place in the Africa Cup of Nations semi-finals on Sunday as the record seven-time champions came from behind to defeat Morocco 2-1 in extra time in Yaounde.
Sofiane Boufal's early penalty put Morocco in front in the last-eight tie but skipper Salah equalised for Egypt early in the second half and then made the winner for Mahmoud Trezeguet 10 minutes into extra time.
Egypt will play hosts Cameroon in the semi-finals at the Olembe Stadium in Yaounde on Thursday.
"Now it is time to focus on Cameroon and we go from there but the players gave everything today as in each game and hopefully we will carry on winning," Salah said after collecting his award for man of the match.
"Our goal is to make the people in Egypt happy."
Morocco took a 3-2 lead with one match drawn into the seventh showdown between the north African giants in the marquee African tournament.
Coaches Vahid Halilhodzic of Morocco and Carlos Queiroz of Egypt made two changes each after last-16 victories over Malawi and the Ivory Coast respectively.
Aymen Barkok was introduced on the right side of the Moroccan midfield in place of Imran Louza and forward Munir el Haddadi replaced injured Ayoub el Kaabi.
Star Egypt goalkeeper Mohamed Elshenawy failed to recover from an injury incurred against the Ivorians and Mohamed Abou Gabal took his place.
Midfielder Hamdy Fathy was also ruled out and Ayman Ashraf, normally a defender, came in with Queiroz conscious of the threat posed when Morocco right-back Achraf Hakimi drifts forward.
It took Hakimi just three minutes to make a major impact as Ashraf failed to connect with the ball and fouled the Paris Saint-Germain star, leading to a penalty after a VAR monitor check by the referee.
After fluffing a penalty against the Comoros, Morocco changed takers, and Boufal did not let the Atlas Lions down, slotting his kick into the right corner as Abou Gabal dived in the opposite direction.
The last time Egypt fell behind in the tournament, against Nigeria in their opening group match, they failed to equalise and had to settle for second place behind the Super Eagles in the final standings.
Desperate to atone for conceding the penalty, Ashraf brought a great two-hand parried save out of Morocco goalkeeper Yassine 'Bono' Bounou midway through the opening half.
Egyptian defenders were not shy to shoot from long range and Ahmed Fatouh tested Bounou, with the Sevilla shot-stopper once again proving equal to the task of preventing an equaliser.
Hakimi, who scored a brilliant match-winning goal direct from a free-kick against Malawi at the same ground five days ago, got a set-piece opportunity not far from the box, but fired wide.
Queiroz, the former Real Madrid manager, was constantly agitated and both the referee and the fourth official spoke to him.
The first half ended with Morocco retaining their one-goal advantage, and not much seen of Egypt captain and talisman Salah, with the Liverpool star seeking his second goal of the tournament.
Egypt replaced injured defender Ahmed Hegazy with Trezeguet at half-time and the Aston Villa forward was narrowly wide with a snap shot just four minutes into the second half.
Morocco were under the cosh and assertive Egypt levelled on 53 minutes as Salah tapped in from close range after Bounou could only parry a Mohamed Abdelmonem header off a corner.
Tempers boiled over minutes from time after Hakimi objected to being fouled by Mostafa Mohamed, triggering pushing from the teams and both players were booked by the overworked referee.
As Morocco gradually regained the ascendancy, Abou Gabal rescued Egypt, pushing a Nayef Aguerd header on to the underside of the crossbar, and with no further goals the match went to extra time.
Egypt went ahead on 100 minutes when three Moroccan defenders failed to stop Salah, whose cross was turned in at the far post by Trezeguet.