The tussle in Tenerife was a tale of three penalties, as Pedri missed the first before Yeremy Pino broke the deadlock on the second rebound, but the visitors found themselves level through a terrific Joel Monteiro effort.
La Roja regained the lead through Bryan Gil, only for Andi Zeqiri to make it 2-2 with his successful spot kick, but the referee pointed to the 12-yard mark for the third time in injury time and Zaragoza held his nerve to seal a dramatic success for the Spaniards.
With a rotated Spain side already guaranteed to win the group and Switzerland doomed to compete in League B for 2026-27, the opening exchanges were dull and uneventful, as to be expected from two sides with nothing to play for.
Luis de la Fuente's side were unsurprisingly controlling the ball and briefly upped the ante around the half-hour mark, at which point the hosts won a penalty, which Barcelona protege Pedri failed to convert.
However, Yeremy was well-placed to fire in the second rebound after the visitors failed to clear their lines, and De la Fuente saw fit to make a few alterations for the second period, one of which saw Chelsea's Robert Sanchez introduced in goal.
The ex-Brighton & Hove Albion man was breached just after the hour mark, though, as Swiss substitute Monteiro bulldozed his way through the Roja defence and scored a fabulous solo leveller out of nothing.
The 25-year-old's thunder was then stolen by a fellow substitute, though, as Gil opened his Spain account to restore the hosts' lead five minutes later, thanks in no small part to a mistake from Switzerland's scorer.
Defensive discipline was not in either side's playbook, though, as Zeqiri then dispatched his own spot kick before the effervescent Zaragoza took a tumble inside the box and did the rest from 12 yards, moving Spain onto 16 points from 18 as two-point Switzerland prepare for life in League B.
SPAIN VS. SWITZERLAND HIGHLIGHTS
Yeremy Pino goal vs. Switzerland (32nd min, Spain 1-0 Switzerland)
After 30 minutes of drab, forgettable action, Spain have a penalty, as Alvaro Morata produces an exquisite first touch to evade Eray Comert and is felled from behind by Ricardo Rodriguez as he cuts inside.
Switzerland goalkeeper Yvon Mvogo springs to his right and keeps out Pedri's spot kick, before Remo Freuler blocks Nico Williams's follow-up, but Yeremy arrives at the back post to crash home the second rebound.
Third time lucky for the European champions, and they deservedly lead in Tenerife!
Joel Monteiro goal vs. Spain (63rd min, Spain 1-1 Switzerland)
He missed a glorious chance at the start of the half, but Joel Monteiro more than makes up for it with a phenomenal solo equaliser!
The 25-year-old Young Boys attacker picks the ball up on the right-hand side, whizzes past Alex Grimaldo and bullies Aitor Paredes out of the way before finding a gap in between Sanchez's legs from a tight angle.
Bryan Gil goal vs. Switzerland (68th min, Spain 2-1 Switzerland)
From hero to zero for Monteiro!
Spain retake the lead within just five minutes, as Gil loses the ball at first but shows terrific desire to immediately win it back, as neither Freuler and Monteiro appear to want to take control of the situation.
Gil takes full advantage of that miscommunication, firing in his first Roja goal into the far side of the net from an angle similar to Monteiro's.
Andi Zeqiri penalty goal vs. Spain (85th min, Spain 2-2 Switzerland)
Zeqiri does what Pedri could not! The visitors are awarded a spot kick of their own in the dying embers, as Fabian Ruiz catches Vincent Sierro on the calf with a high kick.
Zeqiri takes on the responsibility and coolly sends Sanchez the wrong way to drag Yakin's men level again; they may be going down, but they are not going down without a fight.
Bryan Zaragoza penalty goal vs. Switzerland (90+2 min, Spain 3-2 Switzerland)
From winning the penalty that could have stolen a point for Switzerland, Sierro is now guilty of giving away the spot kick that will surely condemn the Rossocrociati to defeat!
Sierro can only bring Zaragoza to the ground as he bears down on goal, and the 23-year-old blasts home the decisive spot kick to conclude an enthralling second period.
MAN OF THE MATCH - MARC CASADO
Drawing fouls and winning the ball back like nobody's business, Barcelona starlet Marc Casado ran the midfield show for Spain, winning a staggering 11 of his 12 ground duels with six free kicks won, three tackles and two successful dribbles.
The 21-year-old has earned his Barcelona stars this season, and he translated such form into a man-of-the-match performance in Tenerife, although Comert and livewire substitute Zaragoza were worthy mentions.
SPAIN VS. SWITZERLAND MATCH STATS
Possession: Spain 60%-40% Switzerland
Shots: Spain 21-11 Switzerland
Shots on target: Spain 10-4 Switzerland
Corners: Spain 7-3 Switzerland
Fouls: Spain 11-14 Switzerland
BEST STAT
WHAT NEXT?
The draw for the quarter-finals of the Nations League will be held on Friday, where Spain - as one of the seeded teams - could be paired with any of Italy, the Netherlands, Croatia or Denmark.
As for the relegated Swiss, all eyes will be on next month's World Cup 2026 qualifying draw, which takes place on December 13; either way, the Rossocrociati will be back in action in March alongside Spain in either friendlies or World Cup qualifiers.