An 88th minute goal from substitute Jesus Navas saw Spain advance to the quarter-finals of Euro 2012 on Monday night.
Navas' goal two minutes from time Spain finish top of Group C, while Croatia exited the tournament.
Spain, playing in an unfamiliar light blue kit, dominated the early stages of the game and had over 75 per cent of possession in the opening 15 minutes.
The first half ended without any score, and Vicente del Bosque's side looked comfortable for most of the opening 45 minutes, although Croatia - who had a good penalty appeal rejected after Sergio Ramos made contact with Mario Mandzukic - did a good job of containing them.
Spain continued to dominate early in the second half, but Croatia missed a glorious chance to take the lead when Luka Modric won the ball and ran down the right flank before delivering a superb cross with the outside of his boot that found Ivan Rakitic unmarked at the back post. Rakitic only had Iker Casillas to beat, but his header was brilliantly saved by the Real Madrid goalkeeper.
As the game passed the hour mark, Spain brought on Jesus Navas to replace Fernando Torres, who had seen very little over the ball.
In turn, Croatia brought on Nikica Jelavic and Ivan Perisic for Domagoj Vida and Danijel Pranjic as they started to move more players forward in search of the goal they needed to stand a chance of progressing to the quarter-finals.
Spain, who also brought on Cesc Fabregas, should have finally found the net on 80 minutes when Sergio Busquets was played in on goal but took too long and almost tried to walk the ball into the net, as the world and European champions started to look nervy.
But on 88 minutes, Andres Iniesta beat the Croatian offside trap and found himself through on goal, squaring to Navas who tapped in from two yards out.