Cameroon scored twice with time ticking away on Tuesday to snatch a dramatic 3-2 win over Gambia, secure an Africa Cup of Nations last-16 place, and eliminate Ghana from the tournament.
In an amazing finish in Bouake, Ebrima Colley scored on 85 minutes to put Gambia 2-1 up only for Joseph Gomez to concede an own goal before an added-time Christopher Wooh goal won a thriller.
Defending champions Senegal beat Guinea 2-0 in the other Group C match to finish with nine points and Cameroon edged Guinea for second place on goals scored after both collected four.
Guinea also qualified for the knockout stage as one of the best four third-placed teams while pointless Gambia head home.
Victory for five-time champions Cameroon meant four-time winners Ghana were eliminated after finishing third in Group B on Monday with only two points.
Apart from group winners and runners-up, the best four third-placed teams from the six sections qualify for the round of 16 and at least four of them will have more points than Ghana.
Hosts Ivory Coast, who suffered a stunning 4-0 defeat by Equatorial Guinea on Monday, will survive if Zambia and Tanzania lose their final Group F matches on Wednesday.
Karl Toko Ekambi was restored to the starting line-up by coach Rigobert Song after playing in a draw with Guinea and being an unused substitute in a loss to Senegal.
Although Cameroon are 80 places above Gambia in the world rankings, they came under considerable first-half pressure and were lucky to be level at 0-0 by half-time.
Read more on FRANCE 24 English
Title holders Senegal beat Cameroon to reach Africa Cup last 16
Hosts Ivory Coast on brink of AFCON exit after Equatorial Guinea humbling
AFCON 2024: Morocco labour to point against DR Congo, Bafana Bafana thrash Namibia