Madrid: A lacklustre display in Zaragoza saw Spain humbled 2-1 at home and the Portuguese pip them to top spot.
Spain knew they needed to match or better Portugal's result away to Czechia in order to remain top of their Nations League group.
Sapin dominated the opening proceedings at La Romareda, but a set piece gave Switzerland the lead in the 21st minute.
Ruben Vargas' corner from the left was well met by Manuel Akanji and there was little Unai Simon could do about the perfectly placed header.
Shortly before the break, the Athletic Club goalkeeper did well to deny Xherdan Shaqiri a goal which would have doubled the Swiss lead.
The attacker waltzed through the Spanish defence, but a strong hand from Unai Simon kept the deficit at 1-0 before the interval.
Luis Enrique's side came out determined in the second period and levelled the game in the 55th minute, the Spanish MARCA newspaper reported.
Marco Asensio did excellently to receive the ball in midfield, turn and run at the defence, before sliding through a nice pass which released Jordi Alba to smash home.
The lead didn't last long though and about three minutes later, the visitors were back ahead and again it came from a corner.
Breel Embolo celebrated having turned it in, but the last touch may have come from Eric Garcia.
The second Swiss goal prompted Luis Enrique to turn to his bench with a triple substitution, sending on Yeremy Pino, Borja Iglesias and Nico Williams in place of Ferran Torres, Marco Asensio and Pablo Sarabia.
A new-look front three to try to rescue the game.
Marcos Llorente replaced Pedri shortly afterwards and the versatile Atletico Madrid player brought a good save out of Yann Sommer with an effort from distance as Spain turned the screw.
Switzerland generally withstood the pressure well, however, and Spain, despite their domination of the ball, struggled to open the visitors up and get in behind.
The subs looked lively and another of them, Carlos Soler, perhaps went closest to an equaliser but it wasn't to be.
Switzerland end Spain's run of 22 home games undefeated.
The Swiss did their job well, but Spain will be concerned by their lack of creativity and the slowness of their ball movement.
Next up for Luis Enrique's side is a trip to Braga to attempt to reclaim first position in the group from Portugal.