CAST your eye around Europe, and you find a funk about foreigners. Denmark's voters have given the anti-immigration Danish People's Party its fourth successive rise in voting share. The Swiss gave 29% of their votes to the xenophobic Swiss People's Party. An anti-foreigner party is the second-biggest in Norway. A fifth of Flemish voters in Belgium back the far-right Vlaams Belang.

In France, Nicolas Sarkozy won the presidency in May after aping the anti-immigrant rhetoric of the National Front's Jean-Marie Le Pen. He now talks of inculcating French values. Next year, when France has the European Union presidency, he will promote a similar idea at EU level. His new ministry of national identity and immigration has proposed quotas on immigrants from some regions that may be a ploy to keep out the dark-skinned. He has passed a law to limit immigration for family unification, which allows DNA testing to prove genetic ties.

French policy is measured by comparison with recent actions in Italy. After a Romanian migrant killed an Italian woman in Rome, Romano Prodi's government approved a decree to make it easier to expel EU citizens who are deemed a threat to public security. This pandered to the popular prejudice that Italy's half a million Romanian immigrants, often Roma (gypsies), are more criminal than other new arrivals. But it achieved little. Vigilantes attacked Romanians; police destroyed Roma camps. But as of mid-November, only 117 people had been served with expulsion orders; far fewer had actually gone.

Why are Europe's voters and politicians so stirred up? The short answer is that rates of immigration, from inside and outside the EU, are high, and have been rising for years. A report by Goldman Sachs, an investment bank, suggests that since 2001 migration has added 0.5% a year to Europe's workforce. It concludes that immigration in Europe has outstripped even inflows to America. In many European countries the stock of the foreign-born population has never been higher. As much as 24% of the Swiss population was born elsewhere, as was 12% of Belgium's.

The numbers alone do not explain why some countries are anxious and others less so. France and Denmark have foreign-born shares of the population of only 8% and 6.5% respectively. Some countries that are relatively more relaxed about immigration have much bigger shares: Sweden has 12% and Ireland 11%, for example. One explanation is that an inrush of immigrants may not provoke a backlash so long as the economy is strong.

Worries about immigration from poor countries have been around for years. The fresh element in many west European countries is a concern about immigration from new EU members in eastern Europe. Since the accession of eight countries from the region in 2004, followed by Romania and Bulgaria in January 2007, large numbers of migrant workers have moved (often legally and temporarily) from east to west. Britain, Sweden and Ireland opened up fully to workers from the east in May 2004 and have taken in many highly educated migrants, helping to sustain their long economic upswings. Countries that have seen housing booms have imported hundreds of thousands of lower-skilled workers, often from the east.

Spain alone is thought by the European Commission to be home to some 547,000 adults of working age from Romania and Bulgaria. Yet Spaniards, according to a poll this month for France 24, a television station, appear untroubled. They have the sunniest attitudes of all Europeans towards migration, with 43% of respondents saying that immigrants are a boon to Europe and 55% believing that they are good for the economy. The same poll suggested that 42% of Britons think immigrants are good for the economy, although fewer believe they benefit the country overall.

Yet even in Britain there is creeping anxiety about high immigration from within the EU. This is partly to do with foreign nationals (all those skilled Poles in London) who now take roughly half of all the new jobs being created in Britain. Other gripes are that schools, hospitals and roads are getting overcrowded. After its experience since 2004, Britain decided last January to keep its doors shut to migrant workers from Romania and Bulgaria. Gordon Brown, the prime minister, aware of Mr Sarkozy's electoral success, even talked at the Labour Party conference of “British jobs for British workers”. He has pledged to restrict immigrants from any countries that join the EU in future.

Such talk may please voters, but the ebb and flow of EU migrants seems likely to be driven more by economics than by politicians. In the short run the rate of migration within the EU is likely to slow. Demand for foreign labour in western Europe may drop as housing markets slow and construction falls off. Years of strong growth in the east, combined with a steady outflow of workers, have led to serious labour shortages that are driving up wages. That reduces the incentive to leave, and increases the incentive to return.

In truth the bad demographic outlook of much of western and eastern Europe will make the continent increasingly reliant on foreign labour. And one irony is that, for all the current fretting about too many foreigners, a chronic shortage of suitable workers may be felt most acutely in the countries that seem most hostile to outsiders. Germany has kept its labour markets closed to new EU members until 2011, but it now admits to a skills shortage. This month it eased the restrictions on migrant workers in the mechanical and electrical-engineering industries.

Immigration already accounts for most of the limited population growth in Europe. Ageing populations, combined with the natives' lack of ability, or inclination, to do many jobs, mean that more foreign workers are likely to be needed. By one estimate Europe's native-born workforce will shrink by 44m by the middle of the century. Skilled workers will be in especially short supply. Those calling most fiercely for foreigners to go home may come to regret what they wished for.