Just last month, workers from Romania and Bulgaria became the latest among those living in European Union member states to have the right to migrate and work anywhere inside the bloc, a development that contributed to the backlash against the open-borders rules.

Days before the Swiss vote, Geert Wilders, the anti-Islam Dutch politician, issued a report he commissioned from a London consulting firm trying to show that the Netherlands would be better off leaving the European Union. While there has been criticism of the study, carried out by Capital Economics, Mr. Wilders has turned his party’s emphasis from opposition to Islam to opposition to the European Union, and his Party for Freedom is likely to elect the largest number of European legislators from the Netherlands.

A decision by the Netherlands to exit the European Union would mean that “we no longer have to pay billions to Brussels and weak southern European countries, that we can save billions by liberating ourselves from European Union regulations,” Mr. Wilders said in The Hague. “That we can end the mass immigration and stop paying welfare checks to, for instance, the Bulgarians and the Romanians.”

Eamon Gilmore, the Irish foreign minister, said that there was a “growth in the extreme right agenda” across the European Union and that it was “quite xenophobic.” He said the vote would pose “major difficulties” for freedom of movement, which is a “cornerstone of what the E.U. is all about.”

The vote in Switzerland, which is not a member of the European Union but has broad agreements with Brussels, was very close, with the measure favored by just 50.3 percent of those who voted in the referendum. It gives the government three years to come up with legislation imposing immigration quotas and to negotiate with Brussels on how to manage that legislation.