Alvaro Morata's late goal helped Spain qualify for the 2022 World Cup and consigned Sweden to the play-offs.
Sweden goalkeeper Robin Olsen tipped Dani Olmo's shot on to the crossbar with Morata on hand to tap the ball in after 86 minutes.
Luis Enrique's side needed just a point to top Group B while Sweden needed to win to finish above their opponents.
The result means Spain have qualified for a 12th consecutive World Cup finals.
Sweden will have another chance to reach Qatar in the European play-offs in March.
Spain started the brighter with winger Pablo Sarabia curling an effort narrowly wide from 20 yards in the opening exchanges.
The visitors grew into the match and had a number of chances in the first half with forward Emil Forsberg twice going close to breaking the deadlock.
And Alexander Isak should have put Janne Andersson's side in front when through on goal midway through the second period, but the forward snatched at his chance after capitalising on some lapsed defending.
Spain held on after taking a late lead and keep up their run of reaching every World Cup since 1974.
Latest Stories
-
Bawumia’s 8 minutes elite ball that zapped the energy of trigger happy politicians
27 minutes -
It will be a betrayal if National Cathedral saga does not feature in ORAL’s work – Ablakwa
37 minutes -
‘It’s unfortunate we had to protect the public purse from Akufo-Addo’ – Ablakwa on ORAL Team’s mission
1 hour -
Congo lawyers say Apple’s supply chain statement must be verified
2 hours -
Stampede in southwestern Nigerian city causes multiple deaths
2 hours -
Tens of thousands without water in Mayotte as curfew brought in
2 hours -
ORAL: We won’t witch-hunt, we’ll focus on transparency, not revenge – Ablakwa
3 hours -
Attempted robbery: Accused claims he carried cutlass for protection
3 hours -
Excavator operator jailed for stealing
3 hours -
African fans age-shame me for putting on some outfits – Tiwa Savage
3 hours -
Tiwa Savage criticised by female fans for stance on cheating in relationships
4 hours -
Bank of England expected to hold interest rates
4 hours -
Congo river boat sinks killing at least 22
4 hours -
Nigeria approves Shell’s $2.4 billion asset sale to Renaissance
4 hours -
Embattled Liberian speaker questioned by police over parliament fire
5 hours