Emilio Nsue scored a double to follow up his hat-trick against Guinea-Bissau as Equatorial Guinea finished top of the group ahead of Nigeria on goal difference.
Nigeria saw off Guinea-Bissau 1-0 in the group's other game.
Ivory Coast have only failed to get out of the group phase once in the previous nine editions of the tournament, in 2017.
The two-time champions will have to endure a nervy wait to find out if they will go through to the last 16 as one of the four best third-placed sides.
Jean-Louis Gasset's men need a series of results to go in their favour to avoid sliding out of the competition, after suffering their heaviest ever home defeat.
Thousands of Ivory Coast supporters filed out of the stadium late on as Equatorial Guinea scored three goals in 15 minutes to embarrass their opponents.
The Ivorians started brightly but struggled to create any clear-cut chances, with Oumar Diakite's wild effort off target after a poor punch by Equatorial Guinea goalkeeper Jesus Owono their best opportunity in the opening 25 minutes.
Nicolas Pepe appeared to be fouled in the box on the half-hour mark, but the winger decided to stay on his feet and a penalty was not given despite Owono coming out to gather the ball.
Equatorial Guinea grabbed a surprise lead with their first real attack shortly before half-time.
Right-back Carlos Akapo weaved his way past a couple of weak challenges and into the area before squaring for Nsue to divert the ball into the bottom corner.
Ibrahim Sangare briefly thought he had equalised in first-half injury time, but VAR quickly ruled the goal out for a clear offside against the Ivory Coast midfielder.
Sangare wasted an excellent chance less than two minutes after the restart, ballooning the ball high over the bar from close range with only Owono to beat at the back post.
Fiorentina forward Christian Kouame also failed to draw the home side level when face to face with Owono, firing his shot straight at the 'keeper.
Ivory Coast were again denied an equaliser in the 67th minute by VAR for offside after Jean-Philippe Krasso slotted home left-footed.
The underdogs made the Ivorians pay for their profligacy six minutes later, as Pablo Ganet curled a wonderful free-kick into the top corner.
That goal prompted many of the fans in the Alassane Ouattara Stadium to vacate the stands, and the ones who remained were left stunned when Nsue tucked away his fifth goal of the tournament after a quick counter-attack.
Ivory Coast's goal difference, which could prove crucial in the fight for qualification, took another dent with two minutes of normal time remaining, as Jannick Buyla bobbled a shot into the corner from a rebound.
Equatorial Guinea should have rubbed further salt into their opponents' wounds in added time, but Luis Asue's mishit strike with the goal gaping could not take the gloss off a famous victory.
© 2024 AFP