Spain was guaranteed to stay in League A but, if they won, they could qualify for the Final 4 if Portugal lost at the same time against the Czech Republic.
But with this defeat and the victory of Portugal, La Roja is no longer the leader.
On the other side, this success allows Switzerland to avoid a probable descent.
Nations League standings
Nations League: schedule and results
La Roja have their foot on the ball from the start of the match but take their time to build up their actions and thus create a certain false rhythm.
But the Spaniards will quickly be surprised with the opener of Akanji for the Swiss.
On a corner, the defender is alone at the penalty spot and places an uncrossed header which first touches the ground before finishing in the left corner of Unia Simon.
La Roja is punished.
Luis Enrique's men failed to turn the tide and even got one last scare before the break.
Shaqiri eliminates several Spanish players and pierces the defense until appearing in front of Unai Simon but eccentric, his shot is deflected by the Spanish goalkeeper who makes a reflex save.
The Nati return to the locker room leading in the score.
A second half rich in twists and turns
The second period started strong with the Spanish equaliser.
Alba is perfectly served by Asensio on the left side.
The Barcelonian is alone and snaps a dry shot that ends up in the top corner of Sommer (54th).
The reaction is immediate for the Swiss!
On a new corner, it is still Akanji who cuts the ball at the near post.
He arrives in the center just in front of the goals and Embolo is present to push the leather into the back of the net (58th).
The big chances multiply but Sommer saves his team each time (70th, 76th, 93rd).
The Nati will hold until the end and will leave with the three points.
Group 2 is completely revived.