Goals from Theo Hernandez and Randal Kolo Muani saw France book a World Cup final place against Argentina on Sunday and end Morocco's dream of glory.
Hernandez struck after just five minutes, while Kolo Muani added a second just seconds after coming on as a 78th substitute.
Messi, Alvarez Fire Argentina Into World Cup Final
Antoine Griezmann was outstanding for France, while Morocco gave everything and had the French on the back foot for long periods before Kolo Muani's goal.
France coach Didier Deschamps was forced into two changes in his starting 11 with Adrien Rabiot and Dayot Upamecano out with a virus and replaced by Youssouf Fofana and Ibrahima Konate.
Morocco had better news with Naif Aguerd and Romais Saiss passed fit to play after recent muscle problems.
The game was barely five minutes old when Griezmann turned his marker on the edge of the box and found space. Although Mbappe's first effort from his pullback was blocked by the defense, Hernandez was in the right place to score with a downwards volley from a narrow angle.
Morocco almost responded immediately, with Azz-Eddine Ounahi forcing a fine save from Hugo Lloris with a dipping shot, while Hakim Ziyech should have done better when he slipped through on the break only to fire tamely wide under pressure.
The whistles from the Moroccan fans were deafening every time France touched the ball, but in the 16th minute Giroud almost silenced them when he hit the post with a powerful shot after the Morocco defense misjudged a bouncing ball.
Saiss was then forced off with a relapse of his injury and replaced by Selim Amallah as the Moroccans looked to take the game to France.
That left them more vulnerable on the break and Mbappe missed a chance to make it 2-0, when set clear by Aurelien Tchouameni and Giroud scooped the rebound just wide in the 35th minute.
Jawad El Yamiq ended a thrilling first 45 minutes of football by going close to scoring one of the goals of the tournament, with a spectacular overhead kick following a corner only for Lloris to get his fingers to the ball and tip it onto the post.
Morocco stepped up another gear after the break, as Sofiane Boufal's cross was cleared by Raphael Varane with Youssef En-Nesyri ready to pounce, and Ounahi twisted and turned only for his ball into the six-yard box to be scrambled away.
Suddenly it was all Morocco, with the French forced into some desperate defending. Morocco were seeing over 70 percent of the ball in the second half, compared with just 22 percent in their win over Portugal.
Griezmann was sustaining the French play, working in midfield, defense and attack in a complete performance and substitute Marcus Thuram should have done better with his header from Griezmann's teasing free kick.
Once again Morocco looked to hit back with Abderrazak Hamdallah's run taking him deep into the French area, before Jules Kounde got a vital touch.
Kolo Muani scored France's second in the 79th minute, just moments after he had replaced Ousmane Dembele. The substitute had a simple tap-in at the far post after good work by Thuram and Mbappe.
Morocco still didn't give up, but the ball just would not go in and after the final whistle, the French celebrated, while the Moroccans received the applause of the tens of thousands of fans who have cheered them on in Qatar. It was no less than their efforts deserved.