Morocco shocked title favourites Ivory Coast 1-0 to reach Africa Cup of Nations quarter-final at Stade de Port Gentil.
French born Rachid Alioui scored with a terrific shot from 25 yards to earn a win for Morocco.
The Elephants needed a win to go to the next round having collected just two points from their three group matches and a defeat tonight summed up the disappointing nature of their title defence.
Ivory Coast enjoyed most of the possession early on, but it was Morocco who created chances.They won a a free-kick in third minute but Aurier swung a ball in from a deep position on the right but it was a poor ball that was cleared easily by Morocco.
Morocco first opportunity came in 24th minute when Fajr right-footed fizzing shot had Gbohouo beaten but it slammed into the bar and bounces back but Ivory Coast defender bundled the ball out for a unfruitful corner.
Elephants lacked urgency in their play in the start of second half with Morocco playing a mire poccesion game frustrating their opponents who also needed nothing but a win to proceed.
In the 64th minutes, their efforts were rewarded after picking off possession in midfield and breaking at pace.An accurate pass was played out to Nesyri, on the left, who sent a first time pass inside to Alioui, who took a touch before sending an absolute peach of a shot over the goalkeeper and into the top right corner to put Morocco one foot into the quarter finals.
Ivory Coast had a best chance when Wifrend Konan played a free kick short and left in 74th minute, crossing the ball to Kalou at the back post, who leaped highest as he tried to direct the ball to Kodjia on the back post, only for Morocco to clear.
The Elephants experienced only frustration pushing their men forward but Morocco unyielding in defence to secure a famous victory.
Morocco could have added second in the finals minutes of the encounter but 19-year-old Hamza Mendly shot into the side netting after a good run fro centre of the pitch.
Morocco finish runners-up in Group C with six points, one behind pool winners the Democratic Republic of Congo.
Morocco: Munir Mohand, Medhi Benatia, Hamza Mendyl, Romain Saïss, Manuel da Costa, Mbark Boussoufa, Faycal Fajr (Mounir Obbadi 83’), Nabil Dirar, Karim El Ahmadi, Aziz Bouhaddouz (Rachid Alioui 42’ [Khalid Boutaib 90+2’]), Youssef En-Nesyri
Ivory Coast: Sylvain Gbohouo, Serge Aurier, Serge Wilfried Kanon, Eric Bailly, Simon Deli, Cheick Doukoure (Jean Seri 52’), Wilfried Zaha (Jonathan Kodja 76’), Franck Kessié (Max Gradel 84’),