GENEVA -- 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.

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

The decision means that the Swiss government will need to renegotiate treaties on the free movement of workers that it had painstakingly hammered out with the EU. 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 already 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," said 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 introduce limits on all foreigners' rights to bring in family members or access Swiss social services. EU Commission spokesman Olivier Bailly said that it was disappointed by the vote.

"This goes against the principle of free movement of persons between the EU and Switzerland," he said. "The EU will examine the implications of this initiative on EU-Swiss relations as a whole."

Almost a quarter of the 8 million people living in Switzerland are foreigners. This 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 foreigners compared to other countries.

The People's Party -- which has more than a quarter of seats in the lower house of Parliament -- launched a massive campaign in favour of limiting immigration, hoping to emulate the success of other referendums in recent years that targeted foreigners. Some 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.

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