Alvaro Morata's late goal earned Spain a 1-0 win in Portugal and the last place in the Uefa Nations League finals on Tuesday, while the Czech Republic were relegated from the top tier after losing in Switzerland.
Portugal, winners of the inaugural Nations League in 2019, needed just a point in Braga to finish top of Group A2 but dropped to second as Morata tapped in Nico Williams's header on 88 minutes.
"When we had to stand up, we did," Morata told TVE. "If we had lost, it had to be giving everything we had on the pitch, and that's what we did."
Spain join the Netherlands, Italy and Croatia in the finals which are scheduled for June next year.
Switzerland, who beat Spain 2-1 in Zaragoza on Saturday, were indebted to goalkeeper Yann Sommer as he saved a second-half penalty to preserve victory over the Czechs.
Remo Freuler and Breel Embolo scored within a minute of each other in the first half in St Gallen, but Patrik Schick pulled one back before the break.
Schick saw his second-half penalty kept out by Sommer as the Swiss won 2-1, condemning the Czech Republic to relegation to League B.
Scotland clinched promotion to League A after a 0-0 draw against Ukraine in Krakow, having beaten the same opponents 3-0 last week in Glasgow.
"We don't want to stop, we want to keep getting better," said Scotland coach Steve Clarke.
"These players are desperate to do well for their country and they have had a great week."
Robbie Brady's stoppage-time penalty gave the Republic of Ireland a 3-2 victory over Armenia in Dublin in the other game in Group B1.
Irish captain John Egan and Michael Obafemi put the hosts two goals in front but Armenia equalised as Artak Dashyan and Eduard Spertsyan struck in quick succession.
Dashyan and Hovhannes Hambartsumyan were sent off to leave Armenia with nine players as Brady's winner saw the Irish finish third in the section.
Serbia took top spot in Group B above Norway as forward pair Dusan Vlahovic and Aleksandar Mitrovic got the goals in a 2-0 victory in Oslo.
Mitrovic's strike was his 50th at international level. He scored a hat-trick in Saturday's 4-1 win over Sweden.
Sweden will drop into League C after a 1-1 draw with Slovenia in Solna, where Emil Forsberg cancelled out Benjamin Sesko's opener for the visitors.
Greece made it five wins from six in Group C2 as they beat Northern Ireland 3-1 in Athens. Kosovo thrashed Cyprus 5-1 in Pristina.