Vincent Aboubakar headed in a stoppage-time winner and was then sent off as Cameroon claimed a memorable 1-0 victory over favourites Brazil at the World Cup on Friday, but still failed to go through to the last 16.
Aboubakar, who had come in to captain Rigobert Song's team, connected with a cross from substitute Jerome Ngom Mbekeli to break the deadlock in the 92nd minute at Doha's Lusail Stadium.
He was booked for removing his shirt in the wild celebrations that followed and, having already been cautioned, had to leave his teammates to see out the remainder of the game.
They did so to record a famous win but Switzerland's 3-2 win over Serbia at the same time meant the Swiss advanced from Group G along with already-qualified Brazil.
Having won their first two matches in Qatar, Brazil topped the group and advance to a last-16 tie against South Korea when their many key players who were rested for this game will return.
Coach Tite sent out a second-string side and the result was Brazil's first defeat in the group stage of a World Cup since 1998, when they were beaten by Norway.
Tite's mind was on the knockout stage here as he made nine changes, including handing a start to 39-year-old Dani Alves, making him Brazil's oldest ever men's international player.
The spine of Brazil's second-string side still featured Manchester City's Ederson in goal, Real Madrid's Eder Militao in central defence, Fabinho of Liverpool in midfield, and Gabriel Jesus of Arsenal supported by Rodrygo up front.
They also had the 21-year-old Gabriel Martinelli on the left and the Arsenal prospect was their standout performer.
He almost scored the opening goal in the 14th minute when he leapt unmarked but saw his header tipped over by Cameroon 'keeper Devis Epassy. Martinelli also threatened in first-half stoppage time with a dribble across the edge of the area and a shot that Epassy turned behind.
It was a piece of play reminiscent of Neymar, who is still recovering from the sprained ankle that forced him off in the opening 2-0 win over Serbia but watched the action here from just behind the Brazilian bench.
The Brazil fans, who unfurled a banner with a "Get Well Soon" message for Pele, cheered loudly when Neymar appeared on screens inside the enormous stadium.
Needing a win, Cameroon almost went in front in first-half stoppage time when a Bryan Mbeumo header foced a flying save from Ederson.
Brazil had won all seven previous meetings with African opponents at the World Cup, including beating Cameroon in 1994 and again in 2014, and Martinelli was their most likely source of a goal.
He forced Epassy to tip over another strike that was arcing towards the top corner early in the second half, and the Cameroon shot-stopper -– continuing in place of Andre Onana who was dropped for unspecified disciplinary reasons -– turned a Militao shot around the post moments later.
Eager to study all his attacking options, Tite sent on the Flamengo duo of Everton Ribeiro and Pedro, but he also saw Alex Telles come off hurt in the second half.
Telles is the third Brazil full-back to succumb to injury at the tournament after Danilo and Alex Sandro.
At this rate Alves, a year short of his 40th birthday, will have a further role to play in Qatar.
Most importantly Brazil will hope to have Neymar back soon but it remains to be seen if he will feature against South Korea on Monday.
Aboubakar grabbed the late winner just when a goalless draw looked the most likely outcome, and Cameroon deserve huge credit for taking four points from such a difficult group even if they now go home.
Switzerland edge Serbia in feisty clash
Switzerland booked a last-16 showdown with Portugal at the World Cup on Friday after a 3-2 win over Serbia in a bad-tempered match secured them second place in Group G.
Xherdan Shaqiri's deflected strike put the Swiss ahead but Aleksandar Mitrovic's fine header brought Serbia level at Stadium 974.
Dusan Vlahovic then gave Serbia the lead only for Breel Embolo to equalise before half-time.
Remo Freuler's brilliant goal early in the second half sent the Swiss through to the knockout rounds for the fourth time in five World Cups.
Bad blood marred the meeting between the teams at the 2018 tournament, when Granit Xhaka and Shaqiri celebrated goals by making pro-Kosovo gestures that enraged the Serbs.
Tempers flared in the second half on Friday after Serbia appealed for a penalty, with the stadium announcer calling for an end to "all discriminatory chants and gestures" around 15 minutes later.
Switzerland, who had their destiny in their own hands, nearly struck inside 30 seconds but Embolo's attempt was well blocked by Vanja Milinkovic-Savic, who palmed away the follow-up from Xhaka.
Serbia's Andrija Zivkovic rattled the post from distance with a sweet curling effort and Vlahovic bundled the rebound straight into goalkeeper Gregor Kobel's arms.
Shaqiri missed Switzerland's 1-0 loss to Brazil but returned with a bang as he fired his side in front on 20 minutes.
Ricardo Rodriguez speared a cross into the box which was cleared straight to Djibril Sow, who laid off for Shaqiri to sweep home via the leg of Strahinja Pavlovic in front of the Serbia fans.
This time there was no double eagle gesture. Instead, Shaqiri put his finger to his lips and pointed to the name on his shirt as a handful of bottles rained down.
Serbia hit back within minutes as Switzerland lost the ball in midfield, Dusan Tadic bending in a cross for Mitrovic to meet superbly and nod into the far corner.
Shaqiri steered wide under pressure from Pavlovic after timing his run perfectly to meet Rodriguez's raking diagonal pass, but the Swiss then paid for another lapse in concentration.
They again ceded possession and Freuler watched on in dismay as his attempted interception served only to tee up Vlahovic to roll the ball beyond Kobel.
But Switzerland equalised a minute before the break as Sow picked out Silvan Widmer in acres of space on the right and his driven low cross was turned in by Embolo.
The Cameroon-born striker's pressure on a lumbering Pavlovic gave Switzerland their third goal right after half-time, a brilliant team effort finished by Freuler.
Shaqiri clipped in a delicate ball after Embolo won it back high up, and Ruben Vargas's cushioned backheel left Freuler to guide in from around the penalty spot.
Serbia appealed in vain for a penalty when Mitrovic theatrically fell to the ground, sparking an ugly flashpoint that led to reserve Serbia goalkeeper Predrag Rajkovic being booked.
Substitute Christian Fassnacht spurned a late chance to ease Swiss nerves when clean through on goal.
An unseemly spat between Xhaka and Nikola Milenkovic threatened to boil over, but in the end the Swiss got over the line to set up a date with Cristiano Ronaldo and Portugal.