Achraf Hakimi curled in a long-range free kick as Morocco came from behind to beat Malawi 2-1 in the last-16 of the Africa Cup of Nations on Tuesday and stay on course for their first African title in over 45 years.
Full-back Hakimi's precise strike completed the turn around at the Ahmadou Ahidjou Stadium after Youssef En-Nesyri had equalised on the stroke of half-time.
Malawi went ahead early after a world class goal from Frank Mhango, who hit a speculative left-footed effort from some 40 metres out and watched in delight as the swerving ball caught out Morocco goalkeeper Yassine Bounou and crashed into the top of the net.
After a tournament littered with upsets, Malawi threatened to cause another as Mhango produced an astonishing effort in the seventh minute.
He then had another chance from a quick counter attack in the 23rd minute to double the lead as the lowly ranked Malawi, participating in only their third Cup of Nations finals and getting past the first round for the first time, looked to shake up their heavily fancied opponents.
However, they quickly retreated after that and lived a charmed life, as they defended tenaciously, with goalkeeper Charles Thom producing several unorthodox saves to keep his side's lead intact.
Yet he let a header from En-Nesyri slip through his hands for Morocco's equaliser two minutes into first-half stoppage time and there was little he could do about the rocket-like free kick from Hakimi.
Morocco, who won their only Cup of Nations in 1976, have had a horror run at the tournament since they reached the 2004 final and lost to hosts Tunisia. In six tournaments since they have only reached the quarter-finals once.
Egypt and the Ivory Coast meet in their last-16 clash in Douala on Wednesday.