Spain booked their spot in Qatar after edging Sweden 1-0 in a top-of-the-table Group B clash at Estadio de La Cartuja.
After a goalless first stanza, Alvaro Morata snatched what proved to be the winner for La Roja four minutes before time.
Spain won the group by four points while Sweden qualified for the play-offs.
Serbia sealed automatic qualification ahead of Portugal in Group A after a come-from-behind and last-gasp 2-1 win at Estadio da Luz.
Renato Sanchez gave A Selecao a dream start with the opener within two minutes but Dusan Tadic equalised for the visitors in the 33rd minute and Aleksandar Mitrovic snatched the winner in the last minute.
Serbia finished three points ahead of second-placed Portugal, who had a consolation of qualifying for the play-offs.
Germany, who qualified with a couple of matches to spare, ended Group J with nine victories from ten after drubbing Armenia 4-1 courtesy of a brace by Ilkay Gundogan at Republican Stadium.
Kai Havertz and Gundogan gave Hansi Flick's charges a two-goal cushion going into the half-time before the Manchester City midfielder made it 3-0 early in the second stanza and completed his brace.
Henrikh Mkhitaryan pulled a goal back for Armenia on the hour-mark but Jonas Hofmann put the game to bed for Die Mannschaft four minutes later.
Croatia clinched automatic qualifying spot in Group H by one point after a heart-breaking 1-0 win over Russia at Stadion Poljud.
After a goalless first stanza, Fyodor Kudryashov scored an own goal nine minutes before time to hand the Chequered Ones victory, as they finished one point ahead of second-placed Russia, who had a consolation of qualifying for the play-offs.
Republic of Ireland finished third in Group A after thrashing Luxembourg 3-0 at Stade Josy Barthel.
Following a goalless first stanza, Danen Sinani thought he had found the breakthrough for Ireland early in the second stanza but his goal was disallowed by the Video Assistant Referee (VAR) for a foul in the build-up.
However, Shane Duffy eventually broke the deadlock in the 67th minute, Chiedozie Ogbene doubled their lead 15 minutes before time and Callum Robinson put the game to bed two minutes before time.