Alessandro Gentile poured in 25 points and Marco Belinelli of the Chicago Bulls collected 16 points and eight rebounds in Italy's 86-81 overtime defeat of Spain.
"We went against the best team in the European Championship. We already knew how tough this game would be. But we deserved this win. We never gave up," said Italian guard Pietro Aradori, who scored 17 points in helping Italy take third in Group F with a 3-2 record.
In the final eight, the Italians — looking for their first medal since 2003 bronze — will face off against Lithuania on Thursday.
Spain wasted a 32-point, 10-rebound showing from Marc Gasol in dropping their third game of the tournament and finishing fourth in the group at 2-3.
"I thought that we had the game under control for the first three quarters. We were playing good defence and we were able to run and get easy shots. But then in the fourth quarter... we stepped down defensively and couldn't get back into the game," said the Memphis Grizzlies center.
Spain's quarter-finals opponent Wednesday will be Group E winners Serbia.
Spain came into the day wondering if they would even have a chance to defend their last two titles and still become the first nation to three-peat since Yugoslavia in 1977.
The winner between Spain and Serbia will take on the winners of Wednesday's other quarter between hosts Slovenia and France.
Slovenia finished the group stage on a sour note, losing against Finland 92-76 in a hard fought game — though Slovenia knew beforehand that they were placed second in the group and Finland eliminated.
Bostjan Nachbar paced the Slovenians with 15 points but that wasn't enough as they dropped to 3-2.
Finland, who received 17 points from Gerald Lee, showed a last bit of fight in improving to 2-3 and finished fifth — ahead of Greece.
Needing a victory of their own and a Spain defeat to reach the knockout stage, the Greeks gave Croatia all they could handle but lost in double overtime 92-88.
Bojan Bogdanovic tallied 22 points while Ante Tomic collected 15 points and 12 rebounds as Croatia took Group F honours with a 4-1 record and will face Ukraine in the final eight.
"We are here for the quarter-final game, knowing that Croatia have not played past the quarter-finals in a long time. We are determined to do that. I'm sure we will," said Croatia coach Jasmin Repesa.
The Greeks, considered with a puncher's chance at a podium finish, finished 1-4 despite Yannis Bourousis scoring 21 points and Vassilis Spanoulis hitting for 18 points.
EuroBasket 2013 takes a day off on Tuesday and will resume on Wednesday with the Serbia-Spain and Slovenia-France quarter-finals.