The game saw the return of the Spanish team that had struggled to open up defences despite dominating the ball and passing neatly in their first two games. They did, however, open the scoring through an unfortunate own goal by the incoming Denis Zakaria in the eighth minute; Zakaria turned in a Jordi Alba shot into his own net.
After that, Spain looked effete despite having all the possession and passing neatly. They did offer more threat in extra time against an opposition down by a man.
Switzerland's captain for the night, Xherdan Shaqiri, equalised through a smart finish for his team after a mix-up in the Spanish defence in the 68th minute. But the assist-provider for that goal, Remo Freuler, was sent off through a contentious straight red by Michael Oliver for a hard tackle on Gerard Moreno in the 77th minute.
Spain significantly upped the ante following Freuler's dismissal. But despite mounting resistance, Switzerland held on till penalties, with their keeper Yann Sommer in great form. Both sets of players showed nerves by missing multiple spot-kicks.
In the end, the Swiss fairy tale ended after Mikel Oyarzabal converted the fifth Spanish kick. Switzerland, who had scored from all of their five kicks in a historic win over France in the Round of 16, scored only one of their four against Spain.
Spain, meanwhile, will breathe a sigh of relief and look ahead to a blockbuster semi-final against Italy at the Wembley on Tuesday. On that note, here are the player ratings of both teams from a tense UEFA Euro 2020 quarter-final in St. Petersburg.
Spain Player Ratings
Unai Simon (7/10)
Simon gets an extra mark for saving Fabian Schar and Manuel Akanji's penalties in the shootout. He was blameless for Switzerland's equaliser and was otherwise comfortable when called into action, which was infrequently to say the least. That was in sharp contrast to his horror own goal in the last game. Simon was declared the Man of the Match, possibly because of Spain's shootout success.
Aymeric Laporte (5/10)
Laporte had a tidy game at the back, distributing the ball well while also carrying it forward nicely. But his poor touch led to the ball breaking for Freuler that led to Switzerland's equaliser.
Pau Torres (6/10)
Torres was also partially at fault for Switzerland's equaliser, but he had very little chance from the ball cannoning into him from Laporte's boot. Laporte was good in his defensive duties, keeping the dangerous Seferovic quiet.
Jordi Alba (8/10)
He was excellent while overlapping down the left and looked solid as Spain's left-sided full-back. Alba's shot also led to Spain's only goal in regulation time. He belied his age by being one of the most energetic Spain players on the field. Alba registered a pass accuracy of 93% from 106 passes, made three of four long balls, seven recoveries and four chances in the game against Switzerland.
Cesar Azpilicueta (7/10)
Azpilicueta was the calmness and experience Spain needed at right-back, much like Alba on the other flank. However, he did not go forward as much as he had done in a scoring performance against Croatia.
Sergio Busquets (7/10)
Busquets brought all his experience into play while sitting in front of the Spain defence. His distribution and passing were also great, and so was his ability to break up play. It was unfortunate that he slammed Spain's first penalty in the shootout into the upright.
He has had better games for Spain, as some of his passes against Switzerland went wayward. Koke also missed a few chances to initiate productive attacking moves for Spain. He was generally characteristically neat in possession, though.
Pedri showed his class during a few great touches and passes, but never delivered a telling final ball.
Ferran Torres (6/10)
Torres has been one of Spain's best players in the tournament. He started against Switzerland nicely on the right wing, but the quality he generally brings to the field was missing. That was the case even when he switched to the other wing or played down the centre.
Alvaro Morata (7/10)
Morata toiled exceptionally hard once again, going down to get involved in the play. But he wasn't given good-enough service; hence goalscoring opportunities for him were at a premium.
Pablo Sarabia (7/10)
Though he came off at half-time, possibly due to a muscle strain, Sarabia was quite potent down the left flank. He combined well with Alba to create some threatening moments for Spain.
Ratings of Spain substitutes
Gerard Moreno (6/10)
Moreno had a gilt-edged opportunity to win the game for Spain at the start of the second half of extra time, but the chance went begging. His other shots were also not sharp enough. But he redeemed himself in the tie-break by hammering his spot-kick home.
Danny Olmo (8/10)
Olmo was brilliant down the wings after coming on in the second half. He was a bag of tricks and always a goal threat for Spain. He seemed to have the potential to open up the plucky Swiss defence.
Thiago Alcantara (6/10)
Alcantara tried his best but should have had more influence on the game in the later stages after coming on, considering his magical skill-set. He gets grace points for coming on very late and getting involved from the get-go.
Came on in the 118th minute and also missed his spot-kick.
Marcos Llorente (5/10)
Llorente was brought on to force the issue for Spain late in the game but should have done more as an attacking threat.
Mikel Oyarzabal (6/10)
Although brought on as a wide attacker to help Spain grab the winner in extra time, Oyarzabal failed to do so despite getting into good positions. However, he held his nerve to slot home the all-important final penalty in the shootout.
Switzerland Ratings against Spain
Yann Sommer (8.5/10)
Sommer had a great game and a great tournament overall. He was always assured between the sticks, especially when Spain threw the proverbial kitchen sink at him in extra time, making an impressive ten saves in the match. He leaves Euro 2020 with his head held high despite ending up on the losing side in the shootout.
Silvan Widmer (5/10)
Widmar struggled in the first half to contain Alba and Sarabia down Switzerland's right, as the two overtook him to fashion dangerous openings. Widmer redeemed himself in the second half and also ventured forward on a couple of occasions.
Nico Elvedi (7.5/10)
Elvedi had a fine game at the heart of the Switzerland defence as he did in most of the tournament. He kept the three-man Spain forward line at bay for much of the game.
Manuel Akanji (8/10)
One of the finest defenders at UEFA Euro 2020, Akanji was solid against France and ensured an encore in another tough game. He blunted Morata and played a huge role in ensuring that much of Spain's passing was harmless. He missed a penalty in the tie-break with a poor attempt, but that will not blot a great tournament for him. Akanji won nine of his 12 duels, had a 93% pass accuracy and made 11 recoveries in the loss against Spain.
Ricardo Rodriguez (6.5/10)
The left-back was more solid than his counterpart on the other flank, but Rodriguez could have offered a little more going forward.
Denis Zakaria (6/10)
Drafted into the team to replace the suspended Granit Xhaka, Zakaria scored an unfortunate own goal but was otherwise assured on the ball. He offered little creatively, though.
Remo Freuler (6/10)
Freuler had an eventful game, providing the assist for the equaliser against Spain. He got sent off for a tough boots-up challenge on Moreno in which he got the ball but followed through on to Moreno's shin. Freuler ventured forward more than Zakaria, despite playing as a defensive screen against Spain.
Breel Embolo (N/A)
One of Switzerland's standout performers at Euro 2020, Embolo didn't get any time to show what he could do after being substituted early following a hard tackle, from which he failed to recover.
Steven Zuber (7/10)
Zuber had a fine game down the left wing. He forced the issue down the channel and often got into the Spain penalty box. Zuber nearly scored from open play in the second half and was also energetic in tracking back.
Xherdan Shaqiri (7/10)
Switzerland's captain on the day, Shaqiri netted his team's equaliser with a smart finish and got into the game quite a bit in the second half. Shaqiri wasn't his vintage self against Spain, though, as he misplaced a few important passes.
Haris Seferovic (5/10)
Starved of quality delivery, Seferovic failed to unleash his potency against Spain. He did work hard and often helped out in defence, but he was never really a goal threat.
Ratings of Switzerland substitutes
Ruben Vargas (7/10)
Vargas was an industrious presence down the right and never let his energy ebb after coming on. Unfortunately, he lost his nerve, blasting his penalty over the crossbar in the shootout.
Djibril Sow (7/10)
Sow replaced Shaqiri to add some steel to the Swiss resistance after they went a man down. He did that job proficiently on the night.
Christian Fassnacht (6/10)
Fassnacht came on late in normal time in place of Zuber and spent the extra time busy helping the defence.
Mario Gabranovic (5/10)
Gabranovic did nothing exceptional after coming on in place of Seferovic. Moreover, he also picked up a yellow. He came on with the team down to ten men, which meant he could not offer as much threat as he normally does.
Fabian Schar (N/A)
Schar came on in the second half of extra time and had a few touches. Moreover, he missed the first Swiss penalty in the shootout against Spain.