World Cup 2010 - Holders Italy crash out
Robert Vittek scored either side of the break to give the debutants a 2-0 lead only for Antonio Di Natale to pull a goal back nine minutes from time.
And with the final whistle having gone in Polokwane after a goalless draw between Paraguay and New Zealand, Italy would have reached the last 16 with an equaliser only for Simone Pepe to miss a golden chance deep into injury-time.
Paraguay top Group F ahead of Slovakia while Italy finish bottom of the group behind New Zealand, becoming the fourth World Cup holder to be eliminated at the group stage.
But Marcello Lippi's side are sure to complain about two crucial decisions made by English linesman Darren Cann.
With Italy 1-0 down, he adjudged that Martin Skrtel had prevented the whole ball from crossing the line when he blocked Vincenzo Iaquinta's shot on the line with his knee.
And he denied the Azzuri an equaliser five minutes from time when Quagliarella was adjudged offside after sweeping the ball into the net.
It does not disguise that for the opening hour, Italy were woeful.
It was a sloppy pass from Daniele De Rossi that gave Slovakia the 25th minute lead.
The midfielder gifted the ball away to Juraj Kucka who fed Vittek and the Lille striker produced a slide rule finish into the bottom corner past Federico Marchetti.
It was no more than they deserved as Italy ailed to test Jan Mucha in the first period, indeed the only moment of the concern for the Everton-bound keeper was when Skrtel's header skimmed over the top of his own crossbar.
Lippi made two changes at half-time with Quagliarella coming on and almost immediately Di Natale spurned a great chance from eight yards.
Mucha then flapped at Pepe's cross and Iaquinta smashed a volley towards the goal which was superbly cleared off the line by Skrtel with replays inconclusive, certainly some of the Liverpool defender was behind the line but it was impossible to tell whether the whole ball had crossed the line.
Slovakia were in raptures when they doubled their lead 17 minutes from time. A corner was cleared straight back to Marek Hamsik whose first-time cross was met by Vittek, who got ahead of Giorgio Chiellini at the near post and swept the ball into the net.
But eight minutes later, Italy's World Cup dream flickered again as Di Natale swept the ball into the empty net after Quagliarella was denied by the sprawling Mucha.
Italy thought they were on level terms when Quagliarella stabbed home a cross from the left but the flag was up, the Napoli forward possibly a hair's width in front of the last defender.
And the Italian fans in the crowd were left dumbstruck when they went to sleep from a throw-in which allowed Kopunek to lift the ball over Marchetti with his first touch.
Four minutes of added time were to be played and in the second of those, Quagliarella showed supreme composure to chip the ball into the top corner from 25 yards.
With Slovakian players hitting the deck at regular intervals in an attempt to waste time, English referee Howard Webb played an additional three minutes and in the last of those, a long throw was flicked on and reached Pepe at the back post but he completely shanked his volley wide of the near post from six yards.
It meant Italy failed to successfully negotiate the group phase for the first time since 1974 and for the first time in World Cup history, both the previous finalists from the last tournament fell at the opening stage.
Slovakia v Italy
1st Half Goals 1-0
Shots on Target 4-6
Shots off Target 6-7
Blocked Shots 3-3
Yellow Cards 4-4
Red Cards 0-0
Passing Success 74.3%-74.7%
Tackles Success 70%-80%
Territorial Advantage 51.1%-48.9%