Defending champions Spain are into the quarter-finals after replacement Jesus Navas hit the late winner in their nervy 1-0 victory over Croatia, who bowed out on Monday.
Spain qualify as Group C winners and will now play their quarter-final in Donetsk, Ukraine, on Saturday against the Group D runner-up, while Italy finish second thanks to their 2-0 win over Ireland in Poznen.
Having come on for Chelsea star Fernando Torres in the second-half, Sevilla's Navas hit the 88th-minute winner after Barcelona's Xavi Hernandez chipped the Croatian defence and Andres Iniesta provided the final pass.
The World Cup winners top the group with seven points after their opening draw with Italy and 4-0 rout of Ireland, while there was heartbreak for Slaven Bilic's Croatia.
Spain coach Vicente del Bosque named an unchanged team, while Bilic abandoned the 4-4-2 formation he used in the opening win over Ireland and the draw with Italy for a 4-2-3-1 formation.
On a rare early forage into the Spanish half, Bayern Munich's Danijel Pranjic fired a shot to the left of Spain goalkeeper Ilker Casillas, who dealt with the left-footed shot comfortably on 25 minutes.
Croatia defender Vedran Corluka was booked for dissent soon after as German referee Wolfgang Stark chose not to award a penalty appeal after Spain's Sergio Ramos sliding tackle caught Mario Mandzukic's ankle.
It remained goalless at the break and news of Italy's lead against Ireland raised the tension inside the Gdansk stadium rose noticeably as the second half wore on.
Croatia's best chance came approaching the hour mark when Tottenham Hotspur's Luka Modric crossed in for Ivan Rakitic's header, but Casillas parried away their best chance of the game.
After a fairly ineffective first 60 minutes, Torres made way for Jesus Navas in the three-man forward line, but both sides squandered chances.
With time almost up, the decisive blow came when Xavi Hernandez floated his pass over the defence for his Barcelona team-mate Iniesta to draw Croatia's goalkeeper Stipe Pleitkosa and put Spain in the last eight.
There could be more bad news for Croatia on Tuesday when UEFA are expected to make a ruling over alleged racist chants from Croat fans directed towards Italy striker Mario Balotelli in last week's 1-1 draw.
A stiff penalty is expected given UEFA president Michel Platini's previous assertions that European football's governing body has a "zero tolerance" on the issue.
European football's governing body has already imposed the threat of a six-point reduction on Russia's next European championship qualifying campaign, after missiles and fireworks were thrown at their opening Group A match against the Czech Republic on June 8.