Swiss public radio SRF 4 reported that 50.4 percent of voters appeared to have backed a proposal by the nationalist People's Party to introduce quotas for all types of immigrants.
Some 49.6 percent voted against the plan, but a 0.6-percentage point margin of error meant the outcome could still go either way, said Claude Longchamp of polling organisation gfs.bern.
If the measure is approved then the Swiss government, which along with most political parties opposed the plan, will need to renegotiate painstakingly forged treaties with the European Union on the free movement of workers.
Business groups warned that many of the 80,000 people who moved to Switzerland last year were vital for the country's economy.
At the moment most of the EU's 500 million citizens can live and work in Switzerland with little formality, while Swiss citizens can 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 was already heavily criticised by the EU.
The new proposal would force 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.
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.