Left-back Theo Hernandez put France ahead after just five minutes at the Al Bayt Stadium on Wednesday, firing an acrobatic effort past Yassine Bounou from close range to become the first opposition player to score against the Atlas Lions in Qatar.
Morocco responded forcefully to the early setback, controlling the majority of possession and pressing for an equaliser on either side of half-time.
France, who for large periods were second-best, held out nonetheless and Randal Kolo Muani put the game to bed late, tapping home from close range in the 79th minute to set up a showdown with Argentina in four days’ time.
France are looking to become the first team to retain the World Cup title since Brazil in 1962.
Morocco, the first Arab and first African country to make it to a World Cup semifinal, will face Croatia in a third-place playoff on Saturday.
Atlas Lions never overawed
For the first goal, Hernandez had to lift his left foot high to connect with a bouncing ball from a tight angle to finish off a sweeping move started by Antoine Griezmann’s run down the right and a cutback pass that star French forward Kylian Mbappe initially fluffed.
Denting Morocco’s hopes further, captain Romain Saiss was forced off at the 20-minute mark with an injury, further disrupting a backline that had been shaken pre-match by the last-minute replacement of fellow centre back Nayef Aguerd with Achraf Dari.
Aguerd, who had been named in the starting lineup despite concerns over a hamstring injury sustained earlier in the tournament, was deemed unfit to take part in the match following Morocco’s warm-up.
Attempting to capitalise on the disruption, France striker Olivier Giroud struck the post and missed from point-blank range in the first half at the end of a barnstorming run through the middle from Aurelien Tchouameni.
The midfielder threaded a superb ball to find Mbappe, whose miscued shot was poorly cleared, allowing Giroud a first-time shot that was wide from close-in.
But Morocco were never overawed and had opportunities of their own as Azzedine Ounahi forced two good saves out of French captain Hugo Lloris with speculative efforts, and curling set-pieces put the French defence under pressure.
Replacement centre-back Jawad El Yamiq was, however, closest to an equaliser with a spectacular bicycle kick on the stroke of halftime, from a poorly cleared corner by the French, with Lloris getting a vital touch as it hit the base of the upright.
Morocco fans proud despite defeat
Morocco fans said they were proud of their side despite Wednesday’s loss and focused on the Atlas Lions’ historic showing in the tournament.
“We made history. The players have made us so proud of our country, we can never thank them enough,” Yassine Azami, 35, told Al Jazeera.
Azami, who was visiting Qatar from Tangier, added coach Walid Regragui and his side will be welcomed home with “open arms” in recognition of their “amazing achievements” when they eventually return to Morocco.
Fellow supporter Rahim Behraoui said the Atlas Lions’ efforts in Qatar showed the future was bright for a team that few would have highlighted as serious challengers for world football’s biggest prize before this year’s tournament kicked off.
“We were not the best team today. Congratulations to France,” Behraoui, 46, told Al Jazeera.
“The French were better than us in all areas … but no one can tell us we are not good enough to reach this stage. We showed with Spain, Portugal how good we are,” he added.
“Inshallah we will win this [the World Cup] … if not in four years, then maybe eight.”
Additional reporting by Al Jazeera’s Usaid Siddiqui at Al Bayt Stadium