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.
If the excellent Azzedine Ounahi forced a fine save from Hugo Lloris soon after, there was the feeling that the evening could quickly turn into a rude reality check for them.
When Saiss let a simple forward ball bounce over his head, Olivier Giroud broke away but his shot hit the post.
Then when Saiss came off Regragui abandoned his back three and matched France's 4-3-3.
Morocco finished the half strongly and nearly drew level when, following a corner, defender Jawad El Yamiq saw his overhead kick tipped onto the post by Lloris.
The Atlas Lions then also lost Bayern Munich left-back Noussair Mazraoui at half-time, but France had not been saved from fitness worries themselves.
Two of their starters in the quarter-final win over England, Adrien Rabiot and Dayot Upamecano, were missing due to illness.
Les Bleus have been used to playing semi-finals on a knife-edge and their previous three wins at this stage -- in 1998, 2006 and 2018 -- had all come by a single goal.
Coach Didier Deschamps took off Giroud and replaced him with Marcus Thuram -- son of Lilian -- as Mbappe moved inside.
Kolo Muani then came on for Ousmane Dembele, and with 11 minutes remaining he scored from his first touch, tapping in after another Mbappe shot had been deflected.
The Moroccan players knew then it was game over, and so did French President Emmanuel Macron, standing to applaud in the crowd.
Deccan Herald is on WhatsApp Channels| Join now for Breaking News & Editor's Picks