Cameroon defeated a Brazil side resting a host of regulars but still saw their World Cup campaign end after an entertaining encounter at Lusail Stadium.
Vincent Aboubakar header the winner in stoppage time but his joy immediately turned to disappointment as he was given a second yellow card for taking his shirt off.
Cameroon had acquitted themselves well throughout as Bryan Mbuemo brought an outstanding save from Manchester City's Ederson, deputising for Liverpool keeper Alisson, but Switzerland's victory over Serbia ended their chances of reaching the last 16.
With his side having already qualified after their first two games, Brazil coach Tite made 10 changes and Arsenal's Gabriel Martinelli took the chance to impress with a fine performance in which he was thwarted on several occasions by Cameroon keeper Devis Epassy.
The pre-tournament favourites finished top of Group G despite the loss and now meet South Korea in the knockout phase after their dramatic late win against Portugal saw them edge out Uruguay, who beat Ghana, on goals scored.