Spain's Alvaro Morata came off the bench to strike a late winner as they qualified for next year's World Cup finals in Qatar by beating stubborn visitors Sweden 1-0 in a tense clash.
Morata struck in the 86th minute when he cleverly lifted the ball over Sweden's Robin Olsen after Dani Olmo's fierce drive was pushed onto the post by the keeper and fell into his path.
Spain, who won the 2010 World Cup in South Africa, finished top of Group B with 19 points, four ahead of the second-placed Swedes who could still qualify through the playoffs in March.
In the group's other game, Greece and Kosovo drew 1-1.
Croatia qualified automatically earlier on Sunday after a late Fedor Kudryashov own goal gave them a 1-0 home win over Russia in their crunch Group H qualifier.
Croatia, the 2018 World Cup runners-up, jumped above Russia to top the standings on 23 points from 10 games, one more than the second-placed Russians who will head into the March play-offs.
Croatia dominated a match played in driving rain but a string of good saves by visiting goakeeper Matvei Safonov and a waterlogged pitch kept them at bay before Kudryashov's clumsy 80th-minute touch delighted the home fans.
Elsewhere in Group H, Slovakia finished their campaign with a 6-0 win in Malta to finish third, level on points with fourth-placed Slovenia who beat Cyprus 2-1 in Ljubljana.
Germany midfielder Ilkay Gundogan scored twice in their 4-1 victory over Armenia to finish top of Group J with their seventh straight win under coach Hansi Flick.
Already-qualified Germany, missing a dozen players through injury, suspension and Covid-19 quarantine and having made six changes to the team that beat Liechtenstein 9-0 on Thursday, earned their ninth win in 10 qualifiers to finish in top spot on 27 points. North Macedonia are in second place on 18.
Gundogan struck either side of the break after Kai Havertz had put the visitors in front. Jonas Hofmann also scored for the Germans.
North Macedonia sealed a play-off spot with a 3-1 home win over Iceland that secured them the runners-up spot in Group J, with midfielder Eljif Elmas scoring twice in the second half.
The North Macedonians finished their qualifying campaign on 18 points from 10 games, one ahead of third-placed Romania who ground out a 2-0 win in Liechtenstein.