Cameroon defeated a Brazil side resting a host of regulars but still saw their World Cup campaign ended 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 the African team's 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.
Brazil were in the comfort zone after winning their group games against Serbia and Switzerland, affording coach Tite the opportunity to shuffle his powerful squad while demonstrating the range of resources at his disposal.
They may have lost this game, but with qualification assured Tite may not be too disappointed at the defeat as it did not inflict any damage on their group standing, and he now has fresh legs for when the knockout stage starts.
Arsenal's 21-year-old Martinelli was Brazil's outstanding performer, with Cameroon keeper Epassy producing fine stops from an early header, and a shot destined for the top corner in the second half.
Martinelli's tireless running combined with quality proved a thorn in Cameroon's side and made an eloquent case for his inclusion should Tite wish to make changes as the World Cup progresses.
Brazil have shown enough in their two victories to justify the pre-tournament optimism surrounding their chances - now they will hope Neymar, who acclaimed the fans with his team-mates on the pitch after the final whistle, can recover from the ankle injury sustained against Serbia in time to make his expected contribution.
Cameroon bow out in style
Cameroon may be out of the World Cup but Rigobert Song's side certainly added to the quality and excitement that has marked the group stages here in Qatar.
Brazil had most of the chances at Lusail Stadium but Cameroon were always in the game and posed a threat, which came to fruition when the extrovert Aboubakar directed his header past Ederson during nine minutes of stoppage time.
He paid the price for ripping his shirt off in celebration as referee Ismail Elfath almost apologetically pulled out a second yellow card, followed by the red.
Goalkeeper Epassy also distinguished himself, particularly at the expense of Martinelli, to earn the award as man of the match.
Cameroon were ultimately undone by their opening-game defeat against Switzerland but showed character and quality to fight back from 3-1 down to earn a 3-3 draw against Serbia, and then beat mighty Brazil in front of 85,986 fans here in Lusail.
"The Indomitable Lions" may be going home but they have certainly had their moments in Qatar.
Source: BBC
BDST: 1132 HRS, DEC 03, 2022
SMS