Switzerland's key neighbours have warned that the country's close relationship with the European Union hinged on how it coped with the decision to scrap free movement for EU citizens.

Berlin and Paris voiced dismay over Sunday's Swiss referendum, which decided by a thin majority to introduce quotas for migrants from the EU, scrapping a longstanding agreement with Brussels guaranteeing freedom of movement.

The verdict shocked the European and Swiss elites as it overturned the key pact governing links between the EU and Switzerland, meaning a package of accords partly integrating the country in the EU without being a member could unravel.

A spokesman for the German chancellor, Angela Merkel, said the vote's surprise outcome created "substantial problems". France's foreign minister, Laurent Fabius, said the EU would need to review its relations with Switzerland because of the vote to curb EU citizens' rights.

As anti-immigration campaigners across Europe took delight in the Swiss backlash against newcomers, it was clear that the government in Berne faces a dilemma. The fallout from the vote affects a range of agreements with Brussels that allow the Swiss open access to Europe's single market on everything from selling cheese to competing for public tenders to civil aviation, transport and research.

The strongest warning to the Swiss came from Frank-Walter Steinmeier, Germany's foreign minister. "Cherry-picking with the EU is not a sustainable strategy. The Swiss have damaged themselves with this result. The fair co-operation we have had in the past with Switzerland also includes observing the central fundamental decisions taken by the EU," he said.

Freedom of movement is one of the four keystones of the single market. Switzerland's access to the market – the EU takes 60% of Swiss exports – is based on seven bilateral agreements from 1999, including the free movement pact. The package of seven agreements are interlinked, including guillotine clauses, which means that if one agreement is ditched, the whole package collapses.

For Brussels, said a European commission spokeswoman, free movement is a "sacred liberty. The ball is in the Swiss court. They have to decide what consequences to draw."

Merkel's spokesman, Steffen Seibert, said there would need to be "difficult talks" with the Swiss.

Markus Spillmann, editor of the Neue Zürcher Zeitung in Zurich, said:"The relationship between Switzerland and the EU is now completely open. There will certainly be no good for the economy and for prosperity in this country," he wrote. "Inward-looking Switzerland has won. That's not good for a small, open, resources-poor country."

Sunday's referendum, which passed by 50.3% of votes, was mounted by the populist conservative anti-immigration campaigners of the Swiss People's party. Mainstream politicians, the business community and most urban voters all opposed the immigration caps and were defeated.

The EU and Switzerland are supposed to open negotiations on Wednesday on a new updated framework agreement regulating relations, which have been fraught in recent years because of disputes over banking secrecy and taxation.

The referendum result obliges the Swiss government to cap immigration, but it does not stipulate how and Berne has three years to turn the voters' verdict into law, giving it time to negotiate with Brussels and other EU capitals.

"The referendum did not specify how these measures will be implemented. It only calls for upper bounds on immigration in order to fulfil economic needs," said Reto Föllmi, professor of international economics at the University of St Gallen. "If there is any chance of getting the EU to agree to this, Switzerland must make huge concessions in the other fields of the bilateral negotiations."

But it is difficult to see Brussels diluting freedom of movement to satisfy the Swiss while also allowing Berne preferential access to the single market.

Credit Suisse warned of a negative impact on Swiss growth prospects, foreign investment and job losses, adding that there would be problems finding the right staff for highly qualified jobs.

There are several hundred thousand EU nationals living and working in Switzerland, mainly from Italy, Germany, Portugal and France, while some 450,000 Swiss also live and work in EU countries.

One hundred days before elections to the European parliament, in which immigration will be a central issue, the populist right hailed the Swiss verdict as a template for the rest of the EU.

Geert Wilders, the rightwing Dutch populist, called the Swiss result "fantastic'' and called on the Netherlands to follow suit.

Marine Le Pen, leader of France's National Front, said the same about France. "This Swiss victory will reinforce the will of the French people to stop mass immigration," she said.

In Germany, where Euroscepticism is much weaker, the new anti-single currency party, Alternative for Germany, demanded a referendum on immigration.

And in Austria, Heinz-Christian Strache, leader of the far-right Freedom party, which is currently nudging the top of the opinion polls, called for the same.

If mainstream leaders across Europe are alarmed at the implications of the Swiss vote, analysts said, it is also because they know similar results could be expected in several countries across the EU if single-issue plebiscites were held.

Analysis

Fallout will be closely watched by advocates of new deal for UK

David Cameron has proposed a cap on immigration within the European Union and a dilution of the free movement of labour. Photograph: Murdo MacLeod for the Guardian

Swiss voters have asked a big question of their country's place in Europe. They want fewer Europeans coming to live and work in their country. But the timing and the verdict of Sunday's plebiscite mean that for once Switzerland's direct democracy will echo well beyond its Alpine peaks and valleys.

It will be heard particularly clearly in Britain where David Cameron has been proposing very similar measures to those supported by the Swiss – a cap on migration within the European Union and a dilution of one of the EU's basic liberties, the free movement of labour.

Nowhere will the ensuing wrangle between Brussels and Berne be followed more closely than in London, because of the implications for Cameron's EU referendum and new-deal-for-the-UK campaign.

On the EU side, in trying to resolve the Swiss conundrum an uppermost consideration will be to avoid any concessions on freedom of movement that would encourage British chutzpah in seeking to bend the EU to its will.

No cherrypicking, can't have your cake and eat it, got to take the rough with the smooth. Such were the mantras from Brussels and Berlin on Monday following the Swiss shock. The message might as well be directed at Britain's Conservatives as at the Swiss.

The two cases are very different. Britain is a (relatively) big country in Europe. Switzerland is small, if highly successful and wealthy. Switzerland is not in the EU. Britain is. But the same freedom of movement rules apply to both. Berne will now need to renegotiate the terms of its integration with the EU, just as Cameron insists he wants to renegotiate the terms of Britain's EU membership in order to put a winnable proposition to a Swiss-style plebiscite in 2017 if he is re-elected next year.

Freedom of movement goes to the heart of the single market, the bit that Britain likes most about the EU. It is founded on four freedoms – of goods, services, capital, and labour. Britain has always been the single market's foremost champion, Margaret Thatcher to the fore. It remains so. But it wants to dilute one of its central premises.

There is little evidence to suggest EU migration to Britain over the past decade has done anything but mildly boost economic performance and help the fiscal balance. Swiss economic analysis on Monday reached the same conclusion about the impact of the vote – that it would depress growth, hurt outside investment, damage exports.

The main message from Brussels to the Swiss was that reversing freedom of movement inevitably entails rewriting the entire complex gamut of the confederation's legal relationship with the EU, not to Switzerland's advantage.

The precedent is not a happy one for a Conservative party committed to free trade and the single market. But the popular Swiss verdict also feeds into the European zeitgeist, of hostility to foreigners, of scapegoating, of fears of jobs being lost to outsiders (in a country with the lowest jobless rate in Europe), of social services being abused by non-natives.

The Swiss experience, over the next couple of years, may turn out to be salutary and chastening for a Britain and a Cameron government mulling its European options.

Ian Traynor, Europe editor