Argentina led 2-0, only for two goals from Kylian Mbappe in 100 seconds to force extra time, where Messi scored again, only for Mbappe to again peg Argentina back.
Emiliano Martinez was then the savior, pulling off a vital save in the dying moments of extra time and saving a penalty in the shootout, to add his name to Argentina’s list of heroes.
France coach Didier Deschamps brought back central defender Dayot Upamecano and midfielder Adrien Rabiot, who had both recovered from a virus, while Angel Di Maria was back for Argentina, who played a flat back four, with Nicolas Tagliafico keeping his place at left back.
Argentina started strongly, with their midfield swamping the French, who struggled to get out of their half.
Alexis Mac Allister shot straight at Hugo Lloris in the fourth minute, before Rodrigo De Paul saw an effort deflected for a corner.
Di Maria was looking very lively, but should have done better than blaze over from De Paul’s pullback after Messi had put the midfielder in behind Theo Hernandez.
The winger did a lot better in the 21st minute, turning inside Ousmane Dembele, who then caught his heel. There wasn’t a lot of contact, but it was enough and the referee pointed to the spot.
Messi stepped up to calmly send Lloris the wrong way and net his sixth goal of the tournament.
Argentina continued their control and doubled their lead in the 36th after a magnificent team move that started with Messi and continued with Julian Alvarez, who fed a diagonal ball to the onrushing Mac Allister. Mac Allister looked up and sent in a low cross for Di Maria to slip past the exposed Lloris.
Deschamps responded with a double substitution, replacing Dembele and Giroud, both of whom were well below their best, with Marcus Thuram and Randal Kolo Muani.
It looked as if Deschamps’ team talk was to little effect as Argentina continued to control the second half, even if they were happy to sit a bit deeper.
It wasn’t until the 67th minute that France had a chance, with Kolo Muani heading wide following a corner. France looked dead and buried.
And then they were level.
In the 80th minute, Nicolas Otamendi’s clumsy challenge brought down Kolo Muani and Mbappe sent his spot kick just wide of Emiliano’s dive.
A minute later it was 2-2, France combined in the last third, Kingsley Coman chipped the ball to Mbappe, who did the rest, volleying past Emiliano as the ball dropped over his shoulder.
France stayed on top for most of the first period of extra time, but the best chance fell to Lautaro Martinez, who had just come on as a substitute, and perhaps for that he took an extra touch that allowed a defender to block.
Messi scored again in the 108th minute, firing just the line from close range after Lloris had saved Martinez’s volley, but incredibly Argentina’s celebrations were cut short in the 118th minute when Mbappe’s shot hit Gonzalo Montiel’s arm in the area and Mbappe completed his hat-trick from the penalty spot.
Kolo Muani should have won it for France but Emiliano stuck out a leg to pull off a providential save when the striker was through on goal.
He then saved Coman’s penalty and when Aurelien Tchouameni dragged his effort wide, it was time for Argentina and Messi’s celebrations to begin.