Spain will meet France in the final of the men's Olympic football competition after a 2-1 comeback victory over Morocco.
The 2020 silver medallists fell behind in the first half of the semi-final after tournament top scorer Soufiane Rahimi converted a penalty for his sixth goal at the Games.
Barcelona's Fermin Lopez equalised midway through the second half in Marseille after pouncing on a loose ball in the penalty area.
Substitute Juanlu Sanchez then drilled home a winner five minutes from time to clinch his side's place in Friday's final in Paris, where they will meet Thierry Henry's France side (20:00 BST).
The hosts overcame Egypt 3-1 after extra time in the other last-four tie.
Morocco will face Egypt in the bronze medal match in Nantes on Thursday.