A sensational free-kick from Achraf Hakimi lifted Morocco to a 2-1 win over Malawi and into the Africa Cup of Nations quarter-finals.
Malawi’s Gabadinho Mhango gave his nation a shock lead in the first half with arguably the goal of the tournament from 35-yards out, but a thumping header from Youssef El Nesyri and Hakimi’s set-piece booked Morocco’s place in the last eight.
Vahid Halilhodzic’s side, considered one of the favourites to win the tournament, will play Ivory Coast or Egypt in the next round.
Morocco began the game firmly on the front foot and were piling numbers forward from the first whistle, but Mhango stunned the Atlas Lions with a goal of the year contender in the seventh minute.
The 29-year-old Orlando Pirates striker picked the ball up near the halfway line before he fired a vicious curling strike beyond the helpless Yassine Bounou in goal for his third goal of the tournament.
Mhango came close to scoring again in the 22nd minute as he broke behind the Morocco defence, but he dragged his low strike just wide.
After Watford midfielder Imran Louza hit the bar 10 minutes later, Malawi goalkeeper Charles Thomu was extremely busy. He made great diving saves to deny Achraf Hakimi and Sofiane Boufal from close range.
But on the stroke of half-time Morocco got a deserved equaliser through En Nesyri, powerfully heading in a fine Selim Amallah cross at the far post.
Morocco continued to push for a winner in the second half and they got it in stunning fashion in the 69th minute as Hakimi curled his sublime free-kick into the top corner.