Spain qualified for the 2022 World Cup in Qatar after a tense 1-0 victory over Sweden that was secured by Alvaro Morata's late winner.
Sweden needed to win in Seville on Sunday to top Group B but will go into the play-offs instead after Luis Enrique's home side saw out a nervy final match of their qualifying campaign to clinch the automatic spot.
Emil Forsberg had two clear-cut goalscoring opportunities for Sweden at the Estadio La Cartuja but was unable to test Spain goalkeeper Unai Simon.
Morata gave Spain victory with a close-range strike on the rebound with four minutes of the game left after Dani Olmo had seen his effort hit the crossbar.
Morata said: "We have worked hard to achieve this goal, we have also gone through some tough times together, now every time there are more nerves but more excitement.
"I think we had to be at the World Cup. It is where we have to be, there is no need to celebrate more than necessary, Spain has to be at every World Cup."
Spain showed the early intent and a slick passing move saw Pablo Sarabia cut inside and narrowly shoot wide of the far post with Robin Olsen well beaten.
Sweden weathered the early pressure and Forsberg went close when he curled narrowly wide for the visitors, who began with striker Zlatan Ibrahimovic on the bench.
Spain players celebrate scoring their side's goal. Photo: Jose Luis Contreras/dpa.
A golden chance
Olmo's deflected effort went just over the crossbar midway through the first period before Sweden spurned a golden chance six minutes before half-time.
Ludwig Augustinsson's cross from the left picked out the unmarked Forsberg at the back post, but his volleyed effort flashed just past the post.
Sweden missed two chances shortly after the interval; Cesar Azpilicueta carelessly lost possession but Alexander Isak fired over the crossbar before Forsberg got himself in a tangle after being picked out by Albin Ekdal.
Sandwiched between those opportunities, Spain's Raul de Tomas glanced a header just wide from Sarabia's teasing corner.
Sweden threw on veteran Ibrahimovic with 17 minutes left, but it was Spain who looked more likely to score in the remainder of the contest.
The decisive moment came late in the 86th minute when substitute Morata expertly guided the ball into an empty net after Olmo's effort bounced back out off the woodwork.