Mikel Merino nodded home a last-gasp goal to propel Spain into the semi-finals and knock tournament hosts Germany out of Euro 2024.
Substitute Merino got on the end of Dani Olmo’s cross with 70 seconds of extra-time remaining to silence the crowd in Stuttgart and deny Germany midfielder Toni Kroos a dream farewell on what turned out to be his final game before retirement.
Earlier, Olmo, who plays his club football in Germany for RB Leipzig, had put Spain in front six minutes into the second half of normal time only for Florian Wirtz to snatch a late equaliser for the hosts.
Germany will feel hard done to having created enough chances to have won it but Spain – who finished with 10 men following the late dismissal of Dani Carvajal – had the final say to advance to a last-four clash with either France or Portugal.
Germany coach Julian Nagelsmann hinted beforehand at a more physical approach from his team in an attempt to knock Spain out of their free-flowing rhythm. And that was certainly evident as Kroos crashed into Pedri twice inside the opening seven minutes.
The Barcelona midfielder was hurt by the first challenge – mystifyingly not deemed a booking by referee Anthony Taylor – and had to limp off to be replaced by Olmo.
Pedri had already come close, firing a low shot at Manuel Neuer after just 50 seconds as Spain bossed the early exchanges. Nico Williams shot wide, fellow winger Lamine Yamal fired a free-kick off target and Fabian Ruiz shot over the bar when well placed.
Germany were being overrun in midfield with Kroos struggling to control the tempo and the recalled Emre Can alongside him failing to make any impact.
It took the hosts 21 minutes to create a chance of note, although it should have resulted in the opening goal. Joshua Kimmich found space down the right and his cross was met by Kai Havertz but his header was weak and saved comfortably by Unai Simon.
Arsenal forward Havertz should have again done better 11 minutes before the break. Having latched on to a long ball forward, he failed to get sufficient power on his shot and it was a comfortable save for Simon.
Spain upped the ante at the start of the second period and ought to have taken the lead within two minutes.
Yamal played the ball into the feet of Alvaro Morata but, having rolled marker Jonathan Tah, the Atletico Madrid striker blasted over from eight yards when he seemed destined to score.
It proved a brief respite for Germany as Olmo fired Spain ahead from their next attack. Impressive 16-year-old Yamal was again instrumental, finding space on the right before rolling the ball across the edge of the penalty area where Olmo met it with a crisp shot past Neuer’s despairing dive.
Nagelsmann reacted by bringing on a recognised number nine in Füllkrug as Germany adopted a more direct approach. It almost reaped its reward after 69 minutes when a cross from Maximilian Mittelstadt led to Havertz heading it back for Fullkrug and his lay off was perfect for Robert Andrich, whose shot brought a smart save from Simon.
Havertz threatened again two minutes later with only a brilliant block from Dani Carvajal denying the former Bayer Leverkusen man.
Spain’s defence was coming under real pressure for the first time in the contest and Luis de la Fuente’s men had an almighty scare after 76 minutes. Florian Wirtz got the better of Marc Cucurella down Germany’s right and his low cross was turned onto the post by Füllkrug under pressure from Nacho.
Germany came within inches of an equaliser once again with eight minutes to go – a poor goalkick from Simon latched on to by Havertz but he could not find the net with a chip over the goalkeeper who had raced from his line to make amends.
It was, therefore, no surprise when the equaliser did come in the 89th-minute. Mittelstadt tossed the ball in from the left and Kimmich nodded it back for Wirtz to sweep home via the left-hand post.
The first period of extra-time came and went with one chance apiece, Mikel Oyarzabal shooting inches wide at one end shortly before Wirtz did likewise at the other.
Germany thought they should have had a penalty when Cucurella blocked Musiala’s shot with his hand but Taylor and VAR Stuart Attwell dismissed their appeals.
Germany continued to look the more likely side to snatch a late winner and Simon had to make a great save to keep out Füllkrug’s glancing header with three minutes to go.
But then came Merino’s intervention, created by the brilliant Olmo.
Füllkrug had one more golden opportunity to take it to spot-kicks but he headed wide of the right-hand upright.
Carvajal was shown a second yellow card and the subsequent red in the dying seconds to join Robin Le Normand in missing the semi through suspension.