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 deflected Juraj Kucka's 30-yard free-kick into his own net to give the hosts the lead in the Euro 2016 Group C clash.
Substitute Paco Alcacer equalised for the 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.
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.
Spain have lost four of their last six matches
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.