Swiss voters have narrowly backed a referendum proposal to bring back strict quotas for immigration from European Union countries.
Final results showed 50.3% voted in favour. The vote invalidates the Swiss-EU agreement on freedom of movement.
Fiercely independent Switzerland is not a member of the EU, but has adopted large sections of EU policy.
Brussels said it regretted the outcome of the vote and would examine its implications.
A Yes vote of more than 50% was needed for the referendum to pass.
The BBC's Imogen Foulkes in Geneva says the vote has shown up traditional divisions, with French-speaking areas against the quotas, German-speaking regions divided, and the Italian-speaking canton of Ticino firmly in favour.
A Yes vote means Swiss ministers will have some tricky explaining to do in Brussels, our correspondent says.
In a statement, the European Commission said it regretted that an "initiative for the introduction of quantitative limits to immigration has been passed by this vote.
"This goes against the principle of free movement of persons between the EU and Switzerland. The EU will examine the implications of this initiative on EU-Swiss relations as a whole. In this context, the Federal Council's position on the result will also be taken into account."
The vote comes amid increasing debate across Europe about migration and the impact of free movement of people.
Switzerland's economy is booming at the moment, and unemployment is low, but many Swiss worry about immigration.
A quarter of the eight million-strong population is foreign, and last year 80,000 new immigrants arrived.
Since 2007, most of the EU's 500 million residents have been on an equal footing with locals in the Swiss job market - the result of a policy voted into law in a 2000 referendum.
But a coalition led by the right-wing Swiss People's Party now wants to reverse this deal, saying it was a huge mistake.
Supporters of quotas believe free movement has put pressure on housing, health, education, and transport. They also argue that foreign workers drive salaries down.
But the Swiss government and business leaders say free movement is key to Switzerland's economic success, allowing employers to choose skilled staff from across Europe.
Switzerland's bilateral agreements with the EU took years of negotiation to achieve.
Our correspondent says that abandoning free movement could limit Switzerland's access to Europe's single market, where over half its exports are sold.