Defending champion Ivory Coast were knocked out of the 2017 AFCON after a tiny 1-0 to Morocco.
Rachid Alioui scored with a terrific shot from 25 yards to earn the win for Morocco and their coach Herve Renard, who led the Ivorians to the 2015 title.
Ivory Coast needed a win to go through but gave a listless performance, creating only two chances of note.
Wilfried Zaha shot weakly from 12 yards, while Salomon Kalou’s header from a tight angle clipped a post.
The Elephants lacked urgency in their play and go home after appearing not to put up a fight.
Even after going behind they were unable to cause the organised and disciplined Morocco defence any problems.
Morocco went into the game knowing that a draw was very likely to be enough for them to qualify from Group C and their game plan from the start was to stay compact and hit on the counter-attack.
It served to frustrate their opponents, who opted for the long-ball approach on a shocking pitch and failed to find any penetration.
Morocco could have added a second on the counter-attack but 19-year-old full-back Hamza Mendyl shot into the side netting after running half the length of the pitch.
They will play the winner of Group D in the last eight on Sunday.
DR Congo are also through from Group C, finishing top of the table after beating Togo 3-1.