Match ends, Slovakia 2, Spain 1.
European champions Spain suffered a first qualifying defeat for eight years as former Chelsea player Miroslav Stoch helped earn Slovakia a famous victory.
Iker Casillas misjudged Juraj Kucka's 30-yard free-kick as the hosts took the lead in the Euro 2016 Group C clash.
Substitute Paco Alcacer equalised for Spain with a composed low finish from eight-yards.
But Stoch won it with a close-range header after a cross by Michal Duris.
|Pain for Spain|
|Spain's last qualifying defeat was on 7 October 2006 when a side containing the likes of David Villa and Fernando Torres lost 2-0 away to Sweden in a Euro 2008 qualifier|
The final whistle was greeted by a huge roar as the visitors, who defeated Italy 4-0 in the Euro 2012 final, lost for the first time in 37 World Cup and European Championship qualifying matches, a run stretching back to 2006.
"We showed patience but we were not effective and their keeper was superb," said Spain manager Vicente del Bosque.
Diego Costa, who has scored nine goals in seven Premier League games for Chelsea, has not found the net in six appearances for his country.
Spain, who travel to Luxembourg on Sunday, have three points from two games, while Slovakia head the group with two wins from two.
Elsewhere, England's Group E rivals Lithuania and Slovenia both won.
Switzerland lost for the second straight game as a 79th-minute penalty by Milivoje Novakovic earned Slovenia a 1-0 win.
Lithuania made it two wins out of two as Saulius Mikoliunas struck 14 minutes from time to sink Estonia, who host England on Sunday.
Ola Toivonen's second-half goal earned battling Sweden a 1-1 draw with Russia in Group G after Alexsandr Kokorin had given the visitors the lead in Stockholm.
In the same group, Austria secured a 2-1 win away to Moldova.
Ukraine scored two late goals to win 2-0 away to Belarus in Group C, while Besart Abdurahimi struck deep into stoppage time as Macedonia left it late to beat Luxembourg 3-2.
Also in Group C, Montenegro were held to a goalless draw away to Liechtenstein.
- 15HubocanBooked at 37mins
- 5GyömbérBooked at 90mins
- 19KuckaBooked at 4minsSubstituted forKissat 83'minutes
- 20MakSubstituted forStochat 62'minutesBooked at 87mins
- 7WeissSubstituted forDurisat 54'minutes
- 16Torres BelénSubstituted forCazorlaat 81'minutesBooked at 90mins
- 2AlbiolSubstituted forPedroat 58'minutes
- 21SilvaBooked at 44minsSubstituted forAlcácerat 71'minutes
- 19Diego CostaBooked at 90mins
- 7Garcia Escudero
- 13de Gea
- Björn Kuipers
- Shots on Target
Second Half ends, Slovakia 2, Spain 1.
Attempt missed. Andrés Iniesta (Spain) left footed shot from the centre of the box is too high.
Santiago Cazorla (Spain) is shown the yellow card for a bad foul.
Foul by Santiago Cazorla (Spain).
Miroslav Stoch (Slovakia) wins a free kick on the left wing.
Corner, Spain. Conceded by Marek Hamsik.
Diego Costa (Spain) is shown the yellow card.
Norbert Gyömbér (Slovakia) is shown the yellow card.
Diego Costa (Spain) wins a free kick on the left wing.
Foul by Norbert Gyömbér (Slovakia).
Attempt saved. Diego Costa (Spain) header from the centre of the box is saved in the bottom left corner. Assisted by Cesc Fàbregas with a cross.
Corner, Spain. Conceded by Tomas Hubocan.
Corner, Spain. Conceded by Jan Durica.
Miroslav Stoch (Slovakia) is shown the yellow card for excessive celebration.
Goal! Slovakia 2, Spain 1. Miroslav Stoch (Slovakia) header from the centre of the box to the centre of the goal. Assisted by Michal Duris with a cross.
Foul by Diego Costa (Spain).
Michal Duris (Slovakia) wins a free kick in the defensive half.
Attempt missed. Cesc Fàbregas (Spain) right footed shot from the left side of the box is too high. Assisted by Diego Costa.
Substitution, Slovakia. Filip Kiss replaces Juraj Kucka.