Morocco pulled off yet another World Cup shock, and it was Belgium's aging "Golden Generation" that took the hit this time.
The 2-0 upset left Kevin de Bruyne and the 2018 semifinalists in peril of a group-stage exit at what is likely the final World Cup for numerous players on a team that hasn't been able to win a major title.
Morocco substitute Abdelhamid Sabiri gave his team the lead by whipping in a free kick from a tight angle on the left in the 73rd minute that got under the body of goalkeeper Thibaut Courtois - for many, the best in the world at his position.
Zakaria Aboukhlal then guided a shot into the roof of the net off a pass from Hakim Ziyech in stoppage time as Courtois was beaten again.
Belgium, ranked No. 2 in the world behind Brazil, had won its last seven group games at the World Cup before the upset. It was Morocco's first win at a World Cup since 1998 and only its third ever.
Belgium would have become the second team after defending champion France to qualify for the knockout stage if it had beaten the Moroccans but now will play 2018 finalist Croatia in what will be a crucial final group game.
Morocco, which thrived off the deafening support provided by its fans at Al Thumama Stadium, also had a goal from a free kick by Ziyech disallowed in the first half for offside.Belgium coach Roberto Martinez put in forward Romelu Lukaku, the country's record scorer, as a substitute with less than 10 minutes to go in a desperate attempt to get one back when it was 1-0.
Lukaku hadn't played since October and is only just returning from a left thigh problem.
Belgium reached the semifinals at the 2018 World Cup in Russia, driven by goals from Lukaku, De Bruyne and Eden Hazard, but lost to eventual champion France. The Belgians were also impressive early at last year's European Championship, eliminating Portugal before losing to Italy in the quarterfinals. Italy went on to win that title.
Belgium labored to a 1-0 win over Canada in its opening game in Qatar, when the absence of Lukaku was glaring. Belgium again dearly missed the big striker, who scored four goals at the 2018 World Cup and another four at Euro 2020.
Morocco drew confidence from a 0-0 draw with Croatia in its first game and boosted its chances of reaching the knockout round for first time since 1986 - the only time it has ever advanced.