Cameroon defeated a second-string Brazil team 1-0 in their final Group G match at the Lusail Stadium on Friday but it was not enough as the African side were knocked out of the competition.
Cameroon finished third on four points, two points below second-placed Switzerland, who defeated Serbia 3-2. Brazil, who had already qualified, finished on top on goal difference with six points and will face South Korea in the last 16.
Fred, Antony and Bruno Guimaraes all came close to scoring, while Gabriel Martinelli was the stand-out player for the five-time champions, who looked set for a goalless draw.
But Cameroon finally broke the deadlock when Vincent Aboubakar powered in a header in the third minute of stoppage time before being sent off for collecting a second yellow card for taking off his shirt in the celebration.
Switzerland beat Serbia 3-2 to reach World Cup last 16
Switzerland beat Serbia 3-2 in an incident-packed match on Friday to set up a last-16 meeting with Cristiano Ronaldo's Portugal.
The Swiss finished second in Group G behind Brazil, whose much-changed side lost 1-0 against Cameroon but the South Americans still go through to play South Korea.