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
-
Ghana Fire Service condemns attacks on firefighters, vows legal action
27 mins -
2025 AFCONQ: Angola beat Sudan to top Group F
31 mins -
Tyrese Gibson arrested over unpaid child support, ordered to pay $73K to avoid jail
40 mins -
Online overtakes TV in survey of news habits
1 hour -
Illuminate our highways to save lives – Judge appealsĀ
1 hour -
Apple banks on AI to boost sales of new iPhone 16
2 hours -
Huawei teases tri-fold smartphone, raising competition with Apple in China
3 hours -
Ethiopia hits out at Egypt as Nile dam row escalates
3 hours -
Leader of Nigeria’s labour federation arrested, union says
3 hours -
Tanzania leader condemns killing of opposition figure doused in acid
3 hours -
Selena Gomez says she can’t carry her own children
4 hours -
At least six dead after boat carrying migrants sinks off Senegal
4 hours -
Guinea-Bissau police seize over 2 tons of cocaine on plane from Venezuela
4 hours -
Nigerian officials warn people off church’s ‘miracle’ water
4 hours -
Kenya asks public for help with economic fix laws after protests
5 hours