Alvaro Morata, Rodri and Mikel Oyarzabal were also on the scoresheet in Seville as Joachim Low suffered the heaviest loss of his 14 years in charge.
Germany needed only a point to secure top spot in Group A4 but found themselves 3-0 down by half-time, Spain delivering their best performance under Luis Enrique despite losing Sergio Ramos and Sergio Canales to hamstring problems.
Manchester City's Torres added two more after the break before substitute Oyarzabal piled further pressure on Low, whose position will look increasingly perilous following this chastening defeat.
Morata could hardly believe his luck when he was allowed a free header at the far post from a deep corner by Fabian Ruiz, on as an early substitute for the injured Canales, to open the scoring.
Germany had struggled to get into the game and were fortunate not to be 2-0 down when Morata turned in Torres' cross only to be denied by a contentious offside call.
Manuel Neuer, who became Germany's most-capped goalkeeper as he made his 96th appearance, did superbly to turn Torres' strike around the post as Spain once more got in down the right.
However, he could do nothing to stop Torres smashing a rebound home from six yards after Dani Olmo's header had come back off the crossbar.
It was 3-0 to an utterly dominant Spain five minutes later as a corner from Koke found an unmarked red shirt, this time in the form of Rodri, who glanced a brilliant header out of Neuer's reach.
Ramos went off before the break after hurting his hamstring when sending a long pass forward, but his absence did little to shake Spain from their rhythm.
With Germany pushing for a route back into the match, La Roja sprung a counter-attack down the left and Jose Gaya squared for Torres to steady himself and smash home number four.
Torres secured his treble with 19 minutes to play, sweeping a low shot past a helpless Neuer as Spain once again cut the visiting defence to ribbons, and Oyarzabal was gifted an easy finish when Gaya prodded the ball into his path.
What does it mean? Spain cruise through
Spain needed a victory to reach the last four of the competition but would likely not have expected one to come so easily.
They finish Group A4 with 11 points, two ahead of Germany, who were left to rue that 95th-minute equaliser from Gaya in the reverse fixture in September.
Torres was too much for Germany to handle throughout - he was inches away from another goal and an assist in the second half.
He might only have completed 16 passes, the lowest of any starting Spain player, but the 20-year-old scored from three of his four shots on target and twice teed up potential tap-ins for Morata.
A new Low for Jogi
Germany were unbeaten in their first five games and were in pole position heading into this fixture, yet the 2014 world champions could scarcely have got things more wrong.
Low's set-up of a left-hand side comprising Timo Werner, Toni Kroos and Philipp Max was the most notable weak point of a shockingly fragile team, with Torres exploiting the flank at his leisure.
The scrutiny of Low's plans as attention turns towards the Euros next year is only likely to increase.
Spain, who will feature in next October's Finals, are likewise yet to finalise their plans before they begin their Euros challenge against Sweden on June 14.