Unai Simon was the hero as he made two saves in the shoot-out to send Spain through to the semi-finals of the European Championships.
Luis Enrique's men made a dream start when Jordi Alba's strike from long range deflected off Denis Zakaria, who replaced the suspended Granit Xhaka in the side, and wrongfooted Yann Sommer after eight minutes.
And Switzerland's task was made harder when Breel Embolo went off midway in the first half with a suspected hamstring injury.
Vladimir Petković's side had a string of chances from corners with Manuel Akanji heading over and Zakaria nodding it inches wide after the break.
And they equalised after a mix-up between Pau Torres and Aymeric Laporte led to Xherdan Shaqiri netting from close range.
Spain's players celebrate after winning the UEFA EURO 2020 quarter-final football match between Switzerland and Spain at the Saint Petersburg Stadium in Saint Petersburg on July 2, 2021.
Image credit: Getty Images
The game took another twist when Remo Freuler was shown a straight red for hacking down Gerard Moreno in the closing stages.
But the Spanish were unable to capitalise on their man advantage with Moreno spurning three opportunities in extra time including missing the target from around six yards out.
In the resulting shoot-out Sergio Busquets missed first for Spain, making it six in a row, before Dani Olmo scored his team’s second to level it up before Simon saved Fabian Schar’s effort to make it one miss each.
Sommer and Simon each made another save before the tide turned with Moreno sending a thumping effort into the top corner and then Ruben Vargas skied his effort.
That left it down to Mikel Oyarzabal, who made no mistake and sent his country through to the semis against either Belgium or Italy.
Was it a red card?
Referee Michael Oliver wasted no time in dishing out a card to Freuler and VAR backed his decision. It looked like the correct decision given how high his foot was but the decision certainly divided opinion among current and ex-players on social media.
Switzerland's midfielder Remo Freuler (L) gestures at Spain's midfielder Sergio Busquets (C) after tackling Spain's forward Gerard Moreno during the UEFA EURO 2020 quarter-final football match between Switzerland and Spain at the Saint Petersburg Stadium
Image credit: Getty Images
MAN OF THE MATCH
Yann Sommer (Switzerland). The hero in the penalty shootout against France was on top form again, with a string of impressive saves after his side were reduced to ten men. He kept out Rodri's penalty in the shootout and was unfortunate to be on the losing side again.
SAINT PETERSBURG, RUSSIA - JULY 02: Yann Sommer of Switzerland gives instructions during the UEFA Euro 2020 Championship Quarter-final match between Switzerland and Spain at Saint Petersburg Stadium on July 02, 2021 in Saint Petersburg, Russia.