But Thierry Henry’s men weren’t ready to give up their gold hopes and went on to complete an unbelievable comeback as the game was drawing to a conclusion.
Michael Olise's free-kick from the right appeared to sail through a sea of bodies and into the bottom corner to half the deficit (79').
France were then given a lifeline when the referee pointed to the spot for a penalty after a foul inside the area. Jean-Phillipe Mateta, the man France have relied on for goals throughout this tournament, stepped up and converted it calmly in the 90th minute to send it to extra time.
After that miraculous turnaround, it was clear the hosts had a spring in their step as they spurred forward in search of the go-ahead goal.
Yet completely against the run of play, after a lacklustre start to the extra 30 minutes, second-half substitute Sergio Camello fired Spain ahead with 100 minutes gone to set up a grandstand finish.
Henry’s side continued to push, throwing everything forward, which was ultimately their undoing as goalkeeper Arnau Tenas launched the ball forward into an empty French half for Camello to run onto.
The 23-year-old kept his cool, dinking the ball into an empty net beyond the onrushing Guillaume Restes to make it 5-3 in the 120th minute, bringing to an end this enthralling encounter.
It is Spain’s first football gold medal since Barcelona 1992, a month on from being crowned European Champions.
Gold: Spain Silver: France Bronze: Morocco