Morocco continued their sparkling World Cup form as they defeated Brazil 2-1 in front of 65,000 delighted fans in Tangier on Saturday.
Walid Regragui's side enjoyed a historic finals in Qatar when they reached the semi-finals, beating the likes of Spain and Portugal along the way.
And in their first game since losing to Croatia in the third-place play-off, Morocco recorded their first ever win over the Brazilians at the sold-out Ibn Batouta Stadium.
Midfielder Sofiane Boufal, the former Southampton player now with Al Rayyan in Qatar, gave Morocco the lead after 29 minutes, scoring with a powerful finish.
Brazil captain Casemiro levelled in the 67th minute when his weak shot was fumbled by goalkeeper Yassine Bounou.
But on-loan Sampdoria midfielder Abdelhamid Sabiri struck the winner with a volley in the 79th minute as Morocco showed that becoming the first Arab or African nation to reach the World Cup semi-finals last year was no fluke.
Brazil had a new manager in the dugout with interim coach Ramon Menezes having replaced Tite who stepped down after the World Cup last-eight exit at the hands of Croatia.
Only 10 of the 23-man squad that took Brazil to a disappointing quarter-final exit at the World Cup made the trip to Morocco.
The injured Neymar was again missing with his number 10 shirt passing to Real Madrid youngster Rodrygo. The South Americans also had Los Blancos pair Eder Militao and Vinicius Junior in their starting line-up.
“I wouldn't say we lacked understanding, it's about putting into practice the ideas of a new coach,” said Manchester United's Casemiro.
“I think we played a good game and did everything as far as possible to win.”
Brazil were more aggressive and controlled possession but Morocco were always dangerous on the counter-attack.
Palmeiras winger Rony, who was making his debut, missed a sitter from close range in the 13th minute.
Goalkeeper Bounou almost gifted Brazil a goal in the 22nd minute with a comical mistake while trying to put the ball in play with his feet, but Rony’s shot towards an empty goal was blocked by a defender and Bounou manage to recover in time to save Vinicius’s strike from the rebound.
One minute later, Bono once again made a mistake gifting the ball to Vinicius to finish into an empty goal, but the effort was ruled out by the VAR.
But it was to be Morocco who opened the scoring when Tottenham Hotspur full-back Emerson Royal lost the ball close to his own box that allowed Bilal El Khannous to set up Sofiane Boufal who scored from close range.
Chelsea attacker Hakim Ziyech missed wide two great chances for Morocco before the break while goalkeeper Bounou denied a Rodrygo strike from the edge of the area.
But Brazil found the equaliser in the 67th minute thanks to a dreadful mistake by Bounou, who failed to hold on to a weak shot by Casemiro and let the ball slip under him and inside the net.
However, the locals hit back 12 minutes later with substitute Abdelhamid Sabiri, who took down a lost ball inside the Brazilian box and unleashed an unstoppable strike which bounced off the crossbar into the net.