Theo Hernandez and substitute Randal Kolo Muani scored for France during the 2-0 win to set up a chance of becoming repeat winners for the first time in 60 years.
The French team took just five minutes to breach the best defence of the tournament as Hernandez scored a volley past Yassine Bounou after a scramble in the box.
Olivier Giroud then struck the post from point-blank range in the first half as his side took hold of the game.
Morocco responded in kind with efforts from Azzedine Ounahi forcing two good saves out of French captain Hugo Lloris that put the French defence under pressure.
Jawad El Yamiq then almost equalised with an audacious overhead kick before half time but Lloris again rescued his side as France held on to their 1-0 lead.
Despite Morocco’s dominance in the second half, they failed to find a way past the French defence who scored their second through Kolo Muani who put away Kylian Mbappe’s shot towards to goal to seal the contest.
Morocco, who were decimated by injuries before the game against France, could not reply as their World Cup dream came to an end.
France beat Argentina 4-3 at the World Cup in Russia in 2018 in their last meeting.