France ended Morocco's World Cup dream as goals from Theo Hernandez and Randal Kolo Muani gave the holders a 2-0 win in their semi-final clash and set up a showdown on Sunday with Lionel Messi's Argentina.
It looked like France might make short work of their opponents when Hernandez scored inside five minutes at Al Bayt Stadium, despite having a hostile crowd against them.
But Morocco, the first African and Arab team ever to reach the last four at a World Cup, fought on despite losing key players to injury only to see substitute Kolo Muani seal victory for Les Bleus with a late second.
It will be France's fourth World Cup final in seven editions and they are hoping to become the first team since Brazil 60 years ago to retain the trophy when they take on Argentina at Lusail Stadium on Sunday.
That will be billed as a showdown between Messi and his Paris Saint-Germain teammate Kylian Mbappe, but this match was not about the latter's individual brilliance.
Instead France's victory was down to a team effort against a Moroccan side who will now face Croatia in Saturday's third-place play-off.
Morocco had reached the semi-finals after beating Belgium in the group stage and then knocking out Spain and Portugal.
But whether they could repeat the feat against the holders was another matter, and coach Walid Regragui's plans were left in turmoil by a slew of injuries.
Having missed the quarter-final, centre-back Nayef Aguerd was recalled only to withdraw at the last minute, with Achraf Dari stepping in.
Then fellow defender and captain Romain Saiss had to abandon his teammates after just 21 minutes, and by then Morocco were behind.
France were met by deafening whistles when in possession from the huge Moroccan support but they silenced the crowd with the early opener, Hernandez netting with an acrobatic volley at the back post after Mbappe's shot was deflected.
Remarkably it was also just the second goal conceded by Morocco at this World Cup and the first scored by an opposition player.