Spain book ticket for Euro 2020
Spain became the sixth team to qualify for next year's European championships after Rodrigo Moreno's late equaliser against Sweden in Stockholm.
The Spaniards join Ukraine, Belgium, Russia, Poland and Italy in the tournament which will be played throughout Europe.
"Qualification is a must for a team like Spain but achieving it still has value," said Spain boss Robert Moreno. "It releases the pressure and gives us time to work."
Spain needed only a point but they appeared to have fluffed their lines after Marcus Berg gave the hosts the lead early in the first-half.
Rodrigo's 92nd-minute tap-in sparked celebrations on the touchline and provided a dramatic conclusion to an otherwise fairly smooth campaign for Robert Moreno, who took over in June following the resignation of Luis Enrique.
With two matches remaining, Spain are top of Group F on 20 points, five ahead of Sweden and six above Romania, who missed the chance to take second spot following a 1-1 draw against Norway in Bucharest.
Suspensions for Sergio Ramos and Sergio Busquets meant there were no players who featured in the European championship triumps nor the World Cup victory in South Africa in 2010.
Moreno is attempting to refreshen the roster for impendin major tournaments. Villarreal's Gerard Moreno made his debut up front while Rodri and Inigo Martinez came in for the banned Ramos and Busquets in defence and midfield.
The top two from each of the 10 groups advance to the championships. The other four places will be decided via play-offs.