Final results showed that 61.7 percent of Swiss voters had balked at an initiative to tear up an agreement permitting the free movement of people between Switzerland and the surrounding EU.
The initiative, backed by the populist right-wing Swiss People's Party (SVP) — Switzerland's largest party — had been opposed by the government, parliament, unions, employer organisations and all other political parties out of fear it would jeopardise overall relations with the bloc.
Public support for the initiative had also waned in recent opinion polls, but the suspense had remained high since SVP has eked out surprise victories in the past in its war against tightening relations with the EU.
SVP's initiative called for Switzerland to revise its constitution to ensure it can handle immigration policy autonomously.
The party, which has built its brand by condemning immigration and EU influence, warned that the wealthy Alpine country was facing “uncontrolled and excessive immigration”.
But the government had cautioned that if Switzerland unilaterally voided the free movement accord, a “guillotine” clause will come into force to freeze the entire package of deals with the EU, its largest trading partner.
SVP lawmaker Celine Amaudruz said it was the mention of the guillotine clause that scared people away from the initiative.
EU European Commission head Ursula von der Leyen hailed the result, saying that it “upholds one of the core pillars of our relationship: the mutual freedom to move, to live and to work in Switzerland and the EU”. The EU had been following the vote with concern.
A similar SVP initiative that narrowly passed in 2014 threw Swiss-EU relations into disarray, and it has taken years to mend the damage.
Several other issues were on the ballot Sunday as part of Switzerland's famous direct democracy system.
The voting hinted at a shift in Switzerland's rather traditional approach to family models and gender roles, with more than 60 percent of ballots cast in favour of offering paternity leave for the first time.
Switzerland, which did not grant women the right to vote until 1971, still lags behind much of Europe when it comes to parental leave.
The country first introduced 14 weeks paid maternity leave in 2005 and has until now offered no paternity leave, with new fathers legally entitled to take only one day — the same amount of time granted when moving house.
The Swiss parliament gave the green light for the two-weeks paternity leave last September, but SVP and other opponents had gathered enough signatures to put the issue to a referendum, arguing that taxpayers should not be asked to cover “holidays” for new fathers.
With Sunday's vote, paternity leave will, like maternity leave, offer Swiss parents 80 percent of their salary, up to a ceiling of 196 Swiss francs per day.
Fathers can thus receive a maximum of 2,744 Swiss francs ($3,000, 2,550 euros) during their two weeks of leave.
Adrian Wuthrich, head of the trade union federation Travailsuisse and a supporter of the paternity leave push, hailed Sunday's result. New fathers “finally get more time off than they would for a move,” he told the RTS public broadcaster, stressing though that two weeks should be seen as a minimum.
Fighter jets, wolves
Also on the ballot Sunday was a referendum on dishing out six billion Swiss francs ($6.6 billion, 5.6 billion euros) for new fighter jets, which squeezed through with a mere 50.1 percent of votes in favour.
This should put an end to a more than decade-long debate about replacing Switzerland's ageing fleet of jets, although another vote could be held once the government determines which planes it is looking to buy.
In 2014, the country looked set to purchase 22 Gripen E fighter jets from Swedish group Saab, only to see the people vote against releasing the funds needed to go forward with the multi-billion-dollar deal.
Another referendum Sunday, on a revision of Switzerland's hunting law to make it easier to address country's rapidly growing wolf population, was meanwhile rejected by 51.9 percent of voters.
Voter participation Sunday ticked in at nearly 59 percent, which is exceptionally high in a country where it is rare to see more than 50 percent of voters turn out for the frequent popular polls.