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 quarterfinals 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.
Support InfoStride News' Credible Journalism: Only credible journalism can guarantee a fair, accountable and transparent society, including democracy and government. It involves a lot of efforts and money. We need your support. Click here to Donate