Ivan Perisic struck a sensational winner three minutes from time as Croatia ended Spain's 14-game unbeaten run at the European Championship finals to top Group D after a 2-1 victory on Tuesday.
Spain will now face Italy in the last 16 in Paris on Monday in a repeat of the 2012 final.
Alvaro Morata's early strike got Spain off to a flying start. But despite the absence of Luka Modric through injury, Croatia battled back to equalise before half-time through Nikola Kalinic.
Spain captain Sergio Ramos saw a penalty saved by Danijel Subasic 18 minutes from time.
And that miss proved vital when Perisic snuck the ball home at David de Gea's near post.
Croatia meet one of the best third-placed sides in Lens on Saturday.
Spain could also have to face world champions Germany in the quarter-finals and hosts France in the semi-finals if they are to reach the final in Paris on July 10.
"Now we have to dance with the favourites, but to be champions you have to beat everyone," said Ramos, who vowed Spain will learn from their mistakes.
Coach Vicente del Bosque would rather have avoided an early meeting with the on-form Italians.
- Italy clash -
"It is not ideal, that would have been to finish first (in the group)," said Del Bosque.
"We have to recover well. We are prepared to turn this situation around."
Morata's return to European champions Real Madrid from Juventus had been confirmed earlier on Tuesday.
However, Del Bosque's men were pegged back right on half-time when Perisic's cross from the left was flicked home by Kalinic.
It was the first time Spain had conceded in 11 competitive games stretching back to October 2014 and first time they had conceded in the Euros for a record 733 minutes.
The goal knocked Spain out of their stride as Croatia pushed them onto the back foot at the start of the second period.
De Gea saved from Tin Jedvaj to atone for his own error in flapping at a cross before Marko Pjaca sent an acrobatic effort just wide from the rebound.
Pjaca also had claims for a penalty waved away as Croatia threatened the goal that would have taken them top of the group.
el Bosque withdrew front two Nolito and Morata for the more physical presence of Bruno Soriano and Aritz Aduriz.
Spain were then handed a great chance to retake the lead when referee Bjorn Kuipers adjudged Silva had been pushed by Sime Vrsaljko inside the area.
Modric appeared to send on a message to Subasic when he saw his Real Madrid teammate Ramos step up to take the spot-kick.
And Subasic got lucky as his save was allowed to stand despite the fact he had encroached well before Ramos took aim.
Croatia took full advantage to blow the tournament wide open as Perisic lashed home to round off a clinical counter-attack.
Source: AFP
GMT 08:00 2018 Sunday ,07 January
Oyonnax strike late to hold leaders La RochelleGMT 02:22 2016 Sunday ,03 July
Germany win on penalties to reach Euro 2016 semi-finalsGMT 13:55 2016 Monday ,28 March
Clermont extend Top 14 lead with thrilling winMaintained and developed by Arabs Today Group SAL.
All rights reserved to Arab Today Media Group 2023 ©
Maintained and developed by Arabs Today Group SAL.
All rights reserved to Arab Today Media Group 2023 ©