Voters in Switzerland on Sunday narrowly backed a plan to limit immigration, in a blow for the government after it had warned that the measure could harm the Swiss economy and relations with the European Union.

The move is seen by some as another sign of the anti-immigrant sentiment that has been brewing in several European countries over the years, fueled by anger over economies that have been stagnant since the global financial recession.

Swiss public television SRF reported that some 50.3 percent of voters backed a proposal by the nationalist People's Party to introduce quotas for all types of immigrants. About 49.7 percent voted against the plan. The difference between the two sides was fewer than 30,000 votes, with a turnout of about 56 percent.

The decision means that the Swiss government will need to re-negotiate treaties on the free movement of workers that it had painstakingly hammered out with the EU. Switzerland is not a member of the EU, but until now, citizens from most EU member states could live and work in Switzerland with little formality, while Swiss citizens could do the same in the 28-nation bloc that encircles the Alpine nation.

Two years ago Switzerland introduced quotas for immigrants from eight central and eastern European nations, a move that drew heavy criticism from the EU. Ahead of Sunday's referendum business groups warned that many of the 80,000 people who moved to Switzerland last year are vital for the country's economy, and curtailing immigration further could cost Swiss citizens' jobs too.

"We always thought the argument about jobs would win people over," Urs Schwaller, a lawmaker with the centrist Christian People's Party, told SRF. "Clearly that wasn't enough."

Schwaller said the Swiss government would now need to launch a diplomatic offensive, explaining to the EU that its hands are bound by the referendum while trying to avoid sanctions from Brussels.

"We need to show the European Union that we're a reliable partner," he said.

The new proposal forces the government to draft a law extending quotas to immigrants from Western Europe, and to introduce limits on all foreigners' rights to bring in family members or access Swiss social services.

Almost a quarter of the 8 million people living in Switzerland are foreigners, a statistic that is partly due to Switzerland's healthy economy and high salaries.

But Switzerland's restrictive citizenship laws also mean many people who were born in the country or have lived there for a long time don't have a Swiss passport, inflating the share of resident foreigners compared to other countries.

Switzerland, like many European countries, has seen anti-immigrant and ethnocentric sentiments climb in recent years. Greece’s far-right Golden Dawn party, which has been blamed for stoking violence against immigrants and jews, won nearly 20 seats in parliament in recent elections. In France, a comedian has gained popularity with his “reverse Nazi salute,” which many French people have imitated on social media while standing in front of synagogues. And in November, nine anti-immigration parties from across Europe held a conference to discuss ways to further their cause.

In Switzerland, the far-right People's Party — which has more than a quarter of seats in the lower house of Parliament — launched a massive campaign in favor of limiting immigration, hoping to emulate the success of other referendums in recent years that targeted foreigners.

In a local referendum in the eastern municipality of Au-Heerbrugg last year, voters decided to impose a ban on Muslim girls wearing headscarves at a local primary school.

Some recent campaign posters showed a huge tree crushing a map of Switzerland, while others depicted a heavily veiled woman beneath the headline "1 million Muslims soon?"

According to official figures about 500,000 people in the nation of 8 million identified themselves as Muslim. Many of them are former refugees who fled to Switzerland during the Balkan wars in the 1990s. Only a minority are actively religious.

Al Jazeera and wire services