Champions Italy crashed out of the World Cup as first-time qualifiers Slovakia booked a surprising place in the last 16, with English referee Howard Webb and his assistants denying the Azzurri what looked like a valid equaliser.
Robert Vittek's brace put Slovakia in control but Antonio Di Natale halved the deficit and Fabio Quagliarella looked like he had levelled it at 2-2, but an offside decision went against him.
Substitute Kamil Kopunek made it 3-1 to Slovakia before Quagliarella's brilliant lob gave Italy fleeting hope, but they could not find a third to save their skins and joined fellow 2006 finalists France in bowing out of the tournament.
Italy started positively enough with Di Natale's volley almost catching out Slovakia goalkeeper Jan Mucha inside the first 30 seconds.
Vincenzo Iaquinta then dragged a shot well wide after good link-up play with Di Natale before Napoli midfielder Marek Hamsik, Slovakia's star man and captain, miscued a volley after the ball was flicked on to him by Vittek.
Iaquinta had the ball in the net after 10 minutes but Webb had already blown for a foul by the Juventus forward on defender Jan Durica in the box.
Webb produced his first yellow card for Slovakia midfielder Zdenko Strba, who caught the hard-tackling Gennaro Gattuso late.
Slovakia had to win to go through and they forged ahead in the 25th minute when Daniele De Rossi's stray pass was picked up by Juraj Kucka and he rolled a pass forward to Vittek who directed a low right-foot shot past Italy goalkeeper Federico Marchetti from the edge of the box.
Strba could have made it 2-0 with a fierce 30-yard drive which Marchetti had to dive to his right to push wide for a corner as the half entered its final 10 minutes. Italy were lacking in inspiration and a speculative Riccardo Montolivo effort from long range drifted harmlessly wide.
Liverpool defender Martin Skrtel had to head over his own crossbar from a floated Gattuso cross, and the AC Milan battler then cut open Strba's knee in a tackle. The midfielder asked to continue though, with substitute Kamil Kopunek returning to his seat.
Slovakia ended the half on a high and almost conjured the goal of the tournament when Vittek cleverly worked the ball back to Kucka for a viciously-struck volley which flashed into the side-netting.
Italy brought on forward Quagliarella for Gattuso and Christian Maggio for Domenico Criscito at half-time and they created the first opening of the second half when Iaquinta headed off target from a Simone Pepe cross.
Di Natale should have done better when played in by Maggio after 55 minutes, skewing a shot wide with only Mucha to beat. The biggest Italian cheer of the afternoon to that point greeted Andrea Pirlo's introduction in place of Montolivo, as Azzurri fans hoped he held the key to their revival in the match.
Di Natale hit 29 Serie A goals for Udinese last season but could not find a way past Slovakia as a curling shot from the edge of the box was held by Mucha.
Italy came within a whisker of an equaliser when Pepe's cross sailed over Mucha's head and Quagliarella fired goalwards with the keeper committed, but Skrtel got back to block on the goalline.
The holders were taking more chances, allowing Slovakia to find more space on the break and Miroslav Stoch flashed one shot across Marchetti's goal.
The game looked up for the champions though in the 73rd minute when Hamsik half-volleyed the ball across from the right and Vittek got to it before Giorgio Chiellini to steer it in at the near post.
Italy pulled one back with nine minutes to go after a clever one-two with Iaquinta played Quagliarella in and when Mucha parried his shot, Di Natale was on hand to prod the ball in. There was then a skirmish inside the goal as Quagliarella scrapped with Mucha to retrieve the ball, with Webb booking both men.
Quagliarella thought he had equalised when he turned home a Di Natale cross from the left, but the Napoli man was flagged offside by Darren Cann in the tightest of decisions.
A throw-in by Peter Pekarik then caught Italy sleeping and substitute Kopunek raced through to lob the ball over Marchetti.
Quagliarella pulled one back with a sublime lob but Pepe fluffed their final chance deep into stoppage time.