La Roja were on the cusp of a normal-time victory through Dani Olmo's fine finish, only for Florian Wirtz to come up with an 89th-minute equaliser and force extra time.
However, there was to be one final, critical twist to the tale, as Mikel Merino headed home with the aplomb of a veteran striker to ensure Spain's place in the last four.
Here Sports Mole provides player ratings from Spain's dramatic success.
Spain player ratings vs. Germany: Substitute Olmo steals the show for Spain
GOALKEEPER
Unai Simon - 7/10
Conceded his first goal of this summer's tournament but was still a reliable force in between the sticks for La Roja.
DEFENCE
Daniel Carvajal - 6/10
Dealt with Germany's trickery in attack relatively well. Still in with a chance of adding a second European title of the year to his name. Red card a slight sour note.
Robin Le Normand - 5/10
Struggled to get to grips with Havertz, who failed to punish his opponent after firing a number of good chances off target. Replaced by Real Madrid captain Nacho Fernandez during the half-time interval.
Aymeric Laporte - 6/10
A year in the Saudi Pro League has not lowered the former Manchester City man's quality. Another assured display at the back.
Marc Cucurella - 6/10
Failed to get forward as much as he did in the previous four matches, largely due to the calibre of opposition.
MIDFIELD
Rodri - 7/10
Struggled to get to grips with Musiala in the first period but composed himself during the second 45 to produce a solid display overall.
Pedri - 6/10
Subbed off after eight minutes following two poorly-timed challenges from Kroos. The Barcelona man will be playing that his newly-sustained injury is not a serious one.
Fabian Ruiz - 6/10
Forced off with a minor injury during extra time, provided moments of calm in a frenetic first half as both sides battled for supremacy in the engine room.
ATTACK
Nico Williams - 6/10
Plenty of trickery but failed to create much of note during this quarter-final clash. A harder challenge against better defenders, as expected.
Lamine Yamal - 7/10
A shining light and constant danger on the right flank for La Roja regardless of being up against elite opposition. A menacing run and composed pass for Olmo's goal. Prodigy.
Alvaro Morata - 6/10
Produced an indifferent display for La Roja. Often out of position when the likes of Williams and Yamal looked to find the striker with a cross.
SUBSTITUTES
Dani Olmo - 9/10
A goal and a game-winning assist off the bench for the RB Leipzig attacker. Could have played his way into the XI for the semi-finals next week.
Nacho Fernandez - 6/10
Arrived onto the scene to prevent a Germany equaliser in normal time but was unsuccessful.
Ferran Torres - 6/10
Nothing too significant from the Barcelona winger.
Mikel Merino - 7/10
Provided the match-winning moment with a delightful header. A squad player who has now played a major part in his country's Euro 2024 fortunes.
Mikel Oyarzabal - 6/10
Less influential than his Real Sociedad teammate Merino.
Joselu - 6/10
The Los Blancos favourite did his bit to help La Roja hold out for a hard-fought victory.
Germany player ratings vs. Spain: Antonio Rudiger's reckless evening leads to low rating
GOALKEEPER
Manuel Neuer - 7/10
Plenty of smart stops during his possible final appearance at a major tournament for Germany.
DEFENCE
Joshua Kimmich - 7/10
Contained Williams nicely in the first period and had the energy to burst forward also.
Antonio Rudiger - 5/10
Lots of rash challenges in the first period and picked up a yellow card for his troubles. Lost Merino for Spain's extra-time winner.
Jonathan Tah - 6/10
Came back into the side at the expense of Schlotterbeck and did enough to justify Julian Naglesmann's decision. A good partner for Rudiger at centre-back.
David Raum - 5/10
Fared relatively well in the first half but was too passive in the second, allowing Musiala to dribble in the box and provide an assist for Olmo's goal. Subbed off six minutes later.
MIDFIELD
Emre Can - 6/10
Despite taking the place of Andrich in the starting XI, the former Liverpool man left the enforcer duties to midfield partner Kroos. Replaced during the half-time interval.
Toni Kroos - 6/10
After some reckless tackles during the opening exchanges, Kroos showcased his calm and composure on the ball for the final time in professional football.
Jamal Musiala - 6/10
Threatened to burst into life at multiple points but not as influential as in the previous four matches.
Ilkay Gundogan - 6/10
Struggled to find room for creativity in an engine room dominated by scrappy challenges in the first period. Replaced by target man Fullkrug soon after Olmo's goal.
Leroy Sane - 5/10
Provided Germany with plenty of width on the right side but hardly caused Cucurella any problems. Wirtz took the Bayern Munich man's spot in the team for the second half.
ATTACK
Kai Havertz - 6/10
Excellent in some areas of his play but missing the final bit of quality with his efforts on goal. Slight improvements away from becoming a world-class striker.
SUBSTITUTES
Robert Andrich - 5/10
Did not justify his introduction into the match after the opening 45 minutes.
Florian Wirtz - 7/10
Made a genuine impact when he arrived onto the pitch, scoring the last-minute equaliser for Germany in normal time.
Maximilian Mittelstaedt - 6/10
Replaced Raum after he had been run ragged by Yamal.
Niclas Fullkrug - 6/10
Had a good headed effort to win the contest for Die Mannschaft. Unable to be the super sub this time.
Thomas Muller - 6/10
A farewell to the major tournament stage for Muller ends in a low-key substitute appearance.
Waldemar Anton - 6/10
Unable to help Germany progress into the last four after coming on.