- Álvaro Morata (17')
- Ferran Torres (33', 55', 71')
- Rodri (38')
- Mikel Oyarzabal (89')
Germany were powerless to stop Luis Enrique's relentless side as the visitors suffered their worst defeat in a competitive game and the most humiliating since losing by the same scoreline against Austria in a friendly in 1931.
- Biggest international shocks: Germany's loss to Spain not even their worst
Substitute Mikel Oyarzabal tapped in the sixth goal in the 89th minute to adorn an incredible Spain display and deepen four-times world champions Germany's misery.
"We walked all over them in every sense," said Spain midfielder Rodri. "We scored six but it could have been far more. We are still a group with little experience but this will give us a lot of confidence."
Morata meanwhile took pleasure in silencing Spain's critics after they snatched a 1-1 draw away to Switzerland on Saturday.
"We had the opportunity to send a strong message out to the whole world and we have done just that," he said.
The victory saw Spain finish top of League A4 with 11 points after six games, joining France in the final four tournament, which will take place in October 2021.
"It's definitely a bitter defeat. It's very, very disappointing for us all. I am part of the team. We talk about the we. We screwed this up together. Our body language was disappointing, we did not communicate on the pitch. We should have talked more," German keeper Manuel Neuer said after the match.
The Germans, who only needed a draw to progress to the final phase, came second with nine.
Spain suffered an early injury setback when Sergio Canales was taken off but his replacement Fabian Ruiz had an immediate impact, sending in a superb delivery from a corner and Morata rose unmarked at the far post to head home in the 17th minute.
Morata netted again soon after by connecting with a cross from Ferran but his strike was incorrectly ruled offside, with no VAR in operation in the Nations League.
However, Spain quickly shrugged off any sense of injustice as Ferran smashed in their second goal on the rebound in the 33rd after Dani Olmo had glanced against the post, while Rodri headed home a corner from Koke five minutes later.
Spain lost captain Sergio Ramos to a suspected muscle injury towards the end of the first half on his European record-extending 178th appearance for his country but they grew ever more confident after the break as Germany continued to wilt.
Dani Olmo spurned a chance to add to Spain's lead, allowing Neuer to make a rare save in a match where his main task was picking the ball out of the net on a night when he became Germany's most capped keeper with 96 games ahead of Sepp Maier.
But Ferran showed no mercy, taking a pass from ex-Valencia teammate Jose Gaya to net his second and then receiving a ball from Fabian and beating Neuer from outside the box to become the first Spain player to score a hat-trick against Germany.
"This was one of those nights that happen very rarely, when everything goes exactly as planned. The players went out all fired up and did everything right. This is what you get when you combine quality and attitude," Spain manager Luis Enrique said.
Meanwhile, Germany's beleaguered boss Joachim Low said that "nothing worked out." He explained the Germany team lacked "body language and body tension" and failed to gain control of the match or their opponents.
"We wanted to be courageous," he said. "But nothing worked out. We threw away our concept after the 1-0. We stormed out of position, opened spaces. There was no organisation. There was no communication.
"Every aspect was bad today. There was nothing positive. It was a dark, dark day."