Swiss voters rejected on Sunday a proposal to automatically deport foreign criminals for even minor offences, referendum results showed.
The poll came at a time when many European countries are hardening their attitudes to migrants after more than a million arrived on the continent's shores last year.
Under Swiss law voters can change a law by popular ballot. To be passed it must be approved by a majority of cantons as well as a majority of electors.
According to the final results Sunday evening, the proposal to "automatically deport foreign criminals" was rejected by 58.9 percent of voters.
In a referendum six years ago, more than half of Swiss voters backed strengthening rules to automatically expel foreign nationals convicted of violent or sexual crimes.
The populist right-wing Swiss People's Party (SVP) - which has accused parliament of dragging its feet on writing the text into law and watering it down when it did so last March - proposed tougher rules which were put to the people in Sunday's referendum.
Known for its virulent campaigns against immigration, the European Union and Islam, the SVP had called for "real deportation of criminal foreigners". But the initiative faced stiff opposition, including from the government, parliament and all the other major political parties, which said it circumvented fundamental rules of democracy.
If passed, the proposal would have dramatically increased the number of offences that can get foreign nationals automatically kicked out of Switzerland, including misdemeanours usually punishable with short prison sentences or fines.
It would also have removed a judge's right to refrain from deportation in cases where it would cause the foreign national "serious personal hardship". More than 50,000 people including hundreds of celebrities signed a petition against the proposals.
The SVP's campaign initially garnered strong support, but appears to have lost steam among voters.
Opponents had warned that if the text passed, people born to foreign parents in Switzerland risked being deported to countries they have never lived in, just for petty offences.
"This initiative would have been contrary to the rule of law, as it would have muzzled the judges. That's why we mobilized in this campaign," said Cristina Gaggini, who leads a Swiss organization representing several businesses.
2010 changes sufficient
In the 2010 plebiscite, the Swiss agreed to automatically deport foreigners found guilty of murder, rape and other serious sexual offences, violent crimes like robbery, drug trafficking and abusing social aid.
That proposal was approved by 52.9 percent of those voting. Parliament last year approved changes to the penal code, but also determined that judges should have the right to avoid automatic deportation in certain cases.
The initiative under scrutiny on Sunday would have widened the list of offences that trigger automatic deportation.
Any foreigner found guilty of two lower-level infractions - including fighting, money laundering, giving false testimony and indecent exposure - in the space of 10 years would have been expelled.
According to the Federal Statistics Office, the 2015 changes to the penal code would have led to the deportation of nearly 3,900 people in 2014, compared to around 500 on average.
On the basis of the measures proposed by the SVP, that figure would have been 10,200.
The Swiss were also voting on a range of other issues on Sunday, including the proposed construction of a new road tunnel under the Gotthard pass in the central Swiss Alps.
At 62 percent turnout was higher than at any time since 1992.