Italy produced a passionate and tactically superior display to end Spain's quest for a third consecutive European Championship title and secure a mouth-watering quarter-final tie against world champions Germany.
Using wing-backs Mattia de Sciglio and Alessandro Florenzi to brilliant effect, they were the more potent attacking team until they withdrew in defence of their lead in the final stages.
Giorgio Chiellini scored the game's opening goal, bundling home from close range after David de Gea had parried an Eder free-kick in greasy conditions in the first half.
And Southampton striker Graziano Pelle sealed victory in injury time, volleying home from eight yards after an attempted clearance from substitute Matteo Darmian's cross had looped up invitingly as Italy hit a tiring team on the break.
The scoreline could have been a lot worse for Spain were in not for a series of outstanding saves by Manchester United keeper De Gea. He made three in the first 45 minutes before smothering an effort from Eder in the second half after he had been put clean through by a sublime flick from Pelle.
Italy played with an intensity and fierce determination that hinted at their ambition to avenge their 4-0 defeat in the 2012 final.
It was only in the latter stages that they were subjected to any threatening, sustained pressure - but Sergio Ramos headed wide and Gianluigi Buffon saved long-range efforts from Andres Iniesta and Gerard Pique.
And with full-time looming, Buffon made a brilliant dive to his right to save a close-range effort from Pique before Italy broke clear to score their decisive second.
Spanish newspaper Marca ran the headline 'The End' after Spain were eliminated from the 2014 World Cup in Brazil after just two matches.
If it was not true then it certainly looks it now after La Roja's run as European champions was ended by a team that swarmed all over them and seemed to have a hunger and desire no longer present in their opponents.
Spain boss Vicente del Bosque is out of contract and the side he has so memorably coached since taking over from Luis Aragones after the 2008 European Championship seems in need of fresh impetus.
The fact that they brought on a 35-year-old striker with just one previous international goal in Aritz Aduriz at the break perhaps hints that they are a team that needs a new direction.
Former Spain international Xavi had said in the build-up that this would be a "troublesome match" - and he was correct.
Spain looked like a boxer with too many rounds in the legs and only the imperious Iniesta offered any sense of attacking drive and craft.
Sergio Busquets failed to exert much influence on the tie and David Silva was another peripheral figure on a night when Italy seldom allowed their opponents any time on the ball.
Indeed, if it were not for the brilliance of De Gea the tie would surely have been over by the break. He made three sensational saves - a Pelle header, a brilliant and acrobatic over-head kick from Emanuele Giaccherini that he tipped on to the post and a one-handed effort at full stretch to thwart the same player after he drifted inside from the left.
Chiellini - part of an all-Juventus back three with Leonardo Bonucci and Andrea Barzagli - said before the match that it would be settled by the small details and his side played like a team that left nothing to chance.
From the intensity with which they sang the national anthem to the way in which they took the match to Spain as the heavens opened at the start, they played with an incomparable determination.
And all the while coach Antonio Conte prowled his touchline. He must issue more than a thousand positional instructions during a match and Chelsea fans can look forward to an electrifying presence in the dugout next season.
The speed with which Italy - playing 3-5-2 - transitioned from defence to attack and made the most of wide areas was something their opponents could not contend with.
Spain could not pass their way through a superbly organised Italian side and did not have the speed to get around the edges.
When Pelle scored the decisive second goal with seconds remaining Conte leapt on to his team's dugout.
He might have come into this tournament talking down his team's chances - and said before the match on Monday that Spain were "big favourites" - but he exhibits the body language and drive of a man who believes his side can go a long way.
Italy goalscorer Giorgio Chiellini: "We deserved this win. We could have killed the game off earlier.
"After years of Spain dominating, we have been able to get some revenge. This is just the beginning, we will enjoy this victory but there is still a long way to go until the end. The best is to come."
Spain coach Vicente del Bosque said: "They were probably better. They don't play great football but they are strong in the air, very physical and they were dangerous.
"We came out in the second half with a chance and the players tried to do the best they could. We tried everything but we couldn't score."
Spain go home after suffering their first knockout defeat at a major tournament since the 2006 World Cup, when they undone by Zinedine Zidane's France in Hannover.
Italy can look forward to a quarter-final tie against Germany in Bordeaux on Saturday. They have never lost to the Germans at a major finals - but they will have to do without the suspended Thiago Motta.