World and European champions Spain were never at their most fluent best against a dogged Croatian side despite dominating possession and needed to wait until the 87th minute to settle the match in their favour as substitute Jesus Navas slammed the ball into the vacant net.
With Croatia attempting to find the goal they needed to stay in the tournament, Cesc Fabregas - on for David Silva - picked out Andres Iniesta, who played the ball across the face of goal for Navas to seal the three points.
Spain progress as Group C winners on seven points while Italy join them as runners-up on five points after their 2-0 win over Republic of Ireland, who lost their three games at the finals. Croatia concluded on four points in third place.
If France beat Sweden and England overcome Ukraine in Group D on Tuesday night, there is every chance that England will have to face Spain in a daunting quarter-final in Donetsk on Saturday night. If England win Group D, they will confront Italy in Kiev on Sunday evening.
England manager Roy Hodgson would hope to find Spain in a similar mood in the last eight if that is what fate throws up. They again operated without a forward for parts of the second half as Navas replaced Fernando Torres on 61 minutes. They created few chances as Croatia set out to disrupt their opponents's rhythm with some success.
The first half resembled a training session with Spain seeming to lack urgency and incision as Croatia’s decision to flood the midfield and operate with only Mario Mandzukic up front kept them in the game until the dying moments.
The first half was much ado about nothing apart from a few flares arriving on the pitch at various junctures.Croatia goalkeeper Stipe Pletikosa saved from Torres on 21 minutes while Gerard Pique lifted a shot over the bar a couple of minutes later.
For their part, Croatia forced Iker Casillas to halt a shot from Danijel Pranjic on 24 minutes while Sergio Ramos was fortunate to avoid conceding a penalty when he seemed to take out Mandzukic with a needless late challenge midway through the half.
Spain’s players and certainly their fans looked highly uncomfortable the longer the night staggered on as Casillas produced an excellent save to claw out an Ivan Rakitic header from Luka Modric’s cross on 59 minutes.
Pletikosa made saves from Iniesta and Navas in the closing eight minutes, but Croatia were suddenly proving to be a real threat as outgoing coach Slaven Bilic threw on Nikica Jelavic and Eduardo in the closing minutes to try to save the day.
Spain were fortunate to avoid conceding a penalty a minute before Navas struck as Sergio Busquets was found to be clearly manhandling Vedran Corluka in the box from a Rakitic corner.
It makes you wonder what the officials behind the goal are doing on such occasions. It was perhaps a call that sounded the death knell on Croatian hopes at the finals, but a decision also went for Croatia in the second half when Gerard Pique was caught and felled by the elbow of Mandzukic.
They go out despite clubbing Ireland 3-1 in their opening match and holding Italy 1-1 in their second game.
Spain need one more win or draw to equal the longest unbeaten streak of 10 games at the European Championships, a record held by Netherlands, West Germany and Italy.
They must address how they progress at the tournament without a recognised forward. Alvaro Negredo was sent on in the dying seconds, but there is little doubt that coach Vicente del Bosque is missing David Villa at these finals. Their fans prefer Fernando Llorente, who has yet to appear in this tournament.