Top of the table and taking on a Croatia side lacking the likes of Luka Modric and Mario Mandzukic, Spain's passage to the last 16 as Group D winners appeared straightforward.
Vicente Del Bosque's side were unbeaten at the European Championship since 2004 and had not conceded a goal in the competition for seven matches.
However, strikes from Nikola Kalinic and Ivan Perisic saw Croatia come from behind in Bordeaux to snatch a 2-1 victory, sending Spain to a daunting knockout clash with Italy - and Sergio Ramos must hold his hands up.
The Real Madrid defender is widely regarded as one of the best centre-backs in the game, but he has been unable to live up to that reputation in France.
Ramos picked up a booking against Turkey on matchday two after losing focus early on and was again unimpressive at the Stade de Bordeaux.
It was the 30-year-old who lost sight of Nikola Kalinic shortly before the interval, allowing the Croatia striker to restore parity with a cheeky flick after Alvaro Morata had put Spain ahead.
735 - #ESP have conceded a goal at the Euros for the first time in 735 minutes. Humans.
-- OptaPaolo (@OptaPaolo) June 21, 2016
Things got even worse after the interval, though, with Ramos failing to restore Spain's lead when he had a penalty saved by Danijel Subasic, with his miss proving even more costly in the 87th minute when Ivan Perisic netted the winner for Croatia.
Italy now await in the round of 16 - a repeat of the 2012 final - while Croatia go on to face the third-placed team from Group B (Slovakia), E or F.
Ramos was key to Real Madrid's successful Champions League campaign, netting the opener in the final against Atletico Madrid, but he will have to up his game if he is celebrate more silverware come July.
While Ramos had a match to forget, Morata left the pitch with a smile on his face when he was replaced by Aritz Aduriz midway through the second half.
Real Madrid announced on Tuesday that they had informed Juventus of their decision to bring back Morata after two years at the Serie A champions, and the 23-year-old seems intent on dethroning Karim Benzema as Madrid's first-choice striker.
When Morata left the Bernabeu in July 2014, he was not yet at the level required to give Benzema a run for his money, but he has made significant steps forward since and his performances at the Euros suggest the Frenchman's place could be under threat ahead of the 2016-17 campaign.
Morata might have struggled in Spain's 1-0 win over Czech Republic on matchday one, but he then showed his quality in the 3-0 victory against Turkey, scoring twice in what was a sublime overall performance.
The striker again showcased his predatory instincts in Tuesday's closing group fixture, tapping home from close range in the seventh minute after some great work from David Silva and Fabregas for his third goal at the finals, making him the joint top scorer with Gareth Bale.
He was unable to add a second, but made sure the Croatian defence had to be on high alert at all times with his intelligent runs and clever positioning.
If Morata can continue his goalscoring form from the Euros at Madrid, Zinedine Zidane has a tough decision to make, and one should not be surprised if Benzema loses his place in the BBC strike force that bears his name