Abidjan: Equatorial Guinea defeated host Ivory Coast 4-0 on Monday to win Group A and go to the last 16.
Nigeria, surprise Group B table-toppers Cape Verde, and record seven-time champions Egypt also advanced to the knockout stage.
Nigeria defeated Guinea-Bissau 1-0 to finish second behind Equatorial Guinea, while Cape Verde and Egypt both advanced after a dramatic 2-2 draw.
Ghana conceded two goals in extra time to tie 2-2 with Mozambique, and with only two points, it may not be among the four best third-placed teams that qualify, potentially eliminating them on Tuesday.
Equatorial Guinea, ranked 39 places lower than their opponents in the world, blew away the Ivorian defence in the second half after leading 1-0 at the break.
Emilio Nsue scored twice, bringing his goal tally to five, and Pablo Ganet and Jannick Buyla also scored for a country that frequently outperforms itself in the competition, which began in 1957.
“We knew our opponents were under pressure, so we planned our strategy accordingly,” said Equatorial Guinea coach Juan Micha.