What you need to know:
- The holders had to beat the Ivorians to go through but they trailed 3-0 to goals by Franck Kessie, Ibrahim Sangare and Nicolas Pepe before Riyad Mahrez missed a penalty.
The Ivory Coast crushed an abject Algeria 3-1 on Thursday with Nicolas Pepe among the scorers as the reigning champions crashed out of the Africa Cup of Nations in the group stage.
Franck Kessie and Ibrahim Sangare scored in the first half for the Elephants in Douala, while Pepe added another goal after the break as the Ivory Coast secured top spot in Group E.
Riyad Mahrez hit the post with a second-half penalty before Sofiane Bendebka pulled one back for Algeria with their first goal since arriving in Cameroon, but by then it was too late.
It is the fifth time in the last six Cups of Nations that the reigning champions have failed to make the AFCON knockout phase, but there has arguably never been a worse title defence.
Djamel Belmadi's side came to Cameroon on an unbeaten run stretching back over three years but they were held by Sierra Leone in their opening match and then lost to Equatorial Guinea to suffer a first defeat in 36 matches.
Algeria would have qualified for the last 16 with a win against an Ivory Coast side already guaranteed their place in the knockout rounds, but that never looked like a possibility.
Their demise was lapped up by the fans at the Japoma Stadium in Cameroon's economic capital, with the 50,000-capacity ground filling up as the game went on.
By the time the match was over it looked like fans had taken up more seats than the 60 percent capacity limit imposed as part of coronavirus restrictions, and many invaded the pitch in chaotic scenes of celebration.
The Ivory Coast clearly had the backing of the crowd and they will stay in Douala for a heavyweight last-16 tie next week against Mohamed Salah's Egypt in a repeat of the 2006 final won by the Pharaohs.
Equatorial Guinea through
Equatorial Guinea go through in second place in Group E after defeating Sierra Leone 1-0 in Limbe thanks to a superb first-half strike from Pablo Ganet.
Kei Kamara missed a penalty for Sierra Leone as they go out while Equatorial Guinea will stay in Limbe for a last-16 tie against whoever wins Group F between Gambia, Tunisia and Mali.
The Ivorians had conceded a stoppage-time equaliser in their last game to draw 2-2 with Sierra Leone following a comical mistake by goalkeeper Badra Ali Sangare.
He then learned of the death of his father later that night, but he kept his place in an Elephants team missing Premier League pair Eric Bailly and Wilfried Zaha due to fitness problems.
They went ahead midway through the first half at the end of a great move as Pepe cut the ball back for Kessie to finish low into the corner.
It was 2-0 six minutes before the interval as the unmarked Sangare headed in a Serge Aurier free-kick.
Algeria did not come out fighting after the restart and they might have fallen further behind before Pepe finished superbly in the 54th minute to make it 3-0.
Mahrez then hit the upright on the hour mark from a spot-kick awarded for a soft foul on Youcef Belaili.
They did get a first goal in over four hours of football when Aissa Mandi turned the ball back across goal for substitute Bendebka to score in the 73rd minute, but were spared extra misery when Sebastien Haller's late header was disallowed for offside.