Miroslav Stoch struck a late winner for Slovakia as Spain were condemned to their first qualifying defeat in eight years on Thursday.
The reigning European champions had not lost a qualifier since a 2-0 reverse to Sweden in October 2006, but Stoch's header three minutes from time handed Jan Kozak's side all three points in the Group C clash in Zilina.
Iker Casillas' error allowed Juraj Kucka's long-range strike to fly in as Slovakia took the lead in the 17th minute, but Spain substitute Paco Alcacer looked to have rescued a point - and saved Casillas' blushes - when he controlled Jordi Alba's delivery and slotted home eight minutes from the end.
However, just as it seemed Spain's long unbeaten run would continue, Stoch headed in Michal Duris' excellent delivery at the back post to give Slovakia a memorable win.
Slovakia are now top of the group with six points, while Spain are three behind. Vicente del Bosque's men are joined by Macedonia and Ukraine, who both tasted victory on Thursday.
Macedonia came from 2-1 down with 25 minutes to go to defeat Luxembourg 3-2 at home.
Aleksandar Trajkovski put the home side in front in the 20th minute, only for goals from Stefano Bensi and David Turpel see Luxembourg lead by half-time.
Trajkovski levelled matters from the penalty spot midway through the second period, and Macedonia clinched all three points thanks to Besart Abdurahimi's injury-time winner.
Ukraine left it late to defeat Belarus 2-0 in Borisov, as an Aleksandr Martynovich own goal and a stoppage-time effort from Sergiy Sydorchuk sealed victory.
England thumped San Marino 5-0 at Wembley in Group E to continue their strong start to the campaign.
Phil Jagielka, Wayne Rooney, Danny Welbeck, Andros Townsend and an Alex Della Valle own goal rounded off a routine win for Roy Hodgson's men.
England are joined at the top of the group by Lithuania, who were grateful to Saulius Mikoliunas' 76th-minute goal for their 1-0 success over Estonia, who had Ken Kallaste sent off four minutes from the end.
The other match in the group saw Switzerland fall to a 1-0 defeat in Slovenia, thanks to a Milivoje Novakovic penalty 11 minutes from time.
Sweden - without the injured Zlatan Ibrahimovic - drew 1-1 with Russia in Group G.
Ola Toivonen cancelled out Aleksandr Kokorin's early opener for the visitors, while Sebastian Larsson missed a penalty shortly after the home side had fallen behind.
Elsewhere in the group, captain Marc Janko scored the winner and was also sent off in Austria's 2-1 success in Moldova, and the game between Liechtenstein and Montenegro ended goalless.