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
-
ORAL: We won’t witch-hunt, we’ll focus on transparency, not revenge – Ablakwa
1 minute -
Bawumia joins thousands in Kumasi for burial prayers for Ashanti Regional Imam
3 hours -
Blue Gold Bogoso Prestea Limited challenges government actions in court
3 hours -
Verdicts due for 51 men in Pelicot mass rape trial that shook France
3 hours -
Syria not a threat to world, rebel leader Ahmed al-Sharaa tells BBC
4 hours -
Patrick Atangana Fouda: ‘A hero of the fight against HIV leaves us’
4 hours -
Trinity Oil MD Gabriel Kumi elected Board Chairman of Chamber of Oil Marketing Companies
5 hours -
ORAL campaign key to NDC’s election victory – North America Dema Naa
5 hours -
US Supreme Court to hear TikTok challenge to potential ban
5 hours -
Amazon faces US strike threat ahead of Christmas
5 hours -
Jaguar Land Rover electric car whistleblower sacked
6 hours -
US makes third interest rate cut despite inflation risk
6 hours -
Fish processors call for intervention against illegal trawling activities
6 hours -
Ghana will take time to recover – Akorfa Edjeani
6 hours -
Boakye Agyarko urges reforms to revitalise NPP after election defeat
7 hours