FORTUNE — During Spain’s early 21st century boom, immigration boosted the country’s population from 40.5 million to 46.2 million. But with the onslaught of its economic crisis, some 2.2 million people picked up and left the country, according to Spain’s National Statistics Institute.
Most were immigrants returning home, but 262,000 were Spaniards, many of whom went north to look for work in wealthier countries like England, Germany, and Belgium.
Today, the tide is turning once again and Spaniards are coming home. Amid a rise in populist politics and anti-immigrant sentiment, wealthier European countries have begun to expel cross-European migrants, especially those from southern Europe and from Bulgaria and Romania, which have large Roma populations.
A 2004 EU directive has served as justification for EU countries to expel people who have become an “unreasonable burden on the social assistance system of the host Member State.”
MORE: Can Thailand keep from falling apart?
The number of Europeans expelled from Belgium exploded from 343 in 2010 to 2,712 last year, when 323 Spaniards, 265 Italians, and 176 French lost their residency permits; 1,200 Romanians and Bulgarians were also told to leave. Similarly, to curb so-called welfare tourism, Germany is considering a limit of between three and six months for migrants to find a job or leave.
Katerina Lisenkova, a research fellow at the National Institute of Economic and Social Research, a British think tank, says that anti-immigrant sentiment in the U.K. and Europe is in response to the 2004 expansion of the EU, which brought in 10 new member countries, as well as the recent financial crisis.
“The U.K. experienced a huge influx of immigration after 2004. And in times of hardship, people tend to be less welcoming,” she says.
But while such sentiments may be understandable, they may cause long-term economic pain, and in the short run, they may not save any money.
British Prime Minister David Cameron has said his Conservative Party government aims to reduce annual net immigration from “hundreds of thousands” to “tens of thousands.” In a recent study, Lisenkova and her co-authors modeled what would happen if net immigration was cut in half from its 2012 level of 177,000. The authors found that by 2060 GDP would decrease by 11% and the government would have to raise income taxes by 2.2 percentage points to make up for budget shortfalls.
In addition to providing GDP growth, migrants — even if occasionally unemployed — provide a net short-term economic gain to the countries they move to, says Herbert Brücker, who heads the international comparisons and European integration department at Germany’s Institute for Employment Research.
“Immigrants have higher recipient rates of means-tested benefits and unemployment benefits, about twice as high as natives, but they receive much less benefits from pensions and the health insurance system,” says Brücker.
According to Brücker, studies have shown that immigrants provide an average 2,000-euro net annual gain to Germany. “Germany has a rapidly aging native population, and there is a substantial gain for the welfare state from further immigration, which works particularly well for the pension system,” he says.
The “benefits tourist” — or moocher — appears to be more a rumor than a reality. A recent study commissioned by the European Commission and conducted by GHK, a London consultancy, found that while the number of non-working EU migrants living in EU countries rose from 3 million in 2007 to 4.3 million in 2012, there was little evidence that the main motivation to migrate inside the EU was “benefit-related as opposed to work or family-related.”
The study also found that the “impact of such [benefits] claims on national welfare budgets is very low.” According to the report, non-working EU migrants only accounted for an average of 0.2% of health care expenditures.
“For a wealthy country like Belgium, the financial burden of providing 400 euros a month of social aid to 3,000 people, many of whom have been paying into the social security system for a long time, to me sincerely does not appear excessive,” says Sara Lafuente, a Spanish labor lawyer and a Brussels-based researcher at the EU-funded Changing Employment project.
MORE: The $3.2B Apple-Beats rumor: What the analysts are saying
So, what’s behind the crackdown on EU migrants who lose their jobs or scholarships? Herbert Brücker, the German academic, attributes the change in sentiment to small events that have unsettled the already fragile support for immigration and foreign residents. “You can convince the population for a short time that they need migration economically, but it’s never very popular,” he says.
As catalysts, Brücker points to the small but visible number of Roma immigrants who have clustered in cities like Disbourg, as well as Germany is Digging its Own Grave, a 2010 book in which Bundesbank board member Thilo Sarrazin argues that most of Germany’s immigrants cannot be integrated into its society.
Anti-immigrant rhetoric and high-profile expulsions of a few unemployed visitors may win votes. But these elements may also fray one of the aspects of the EU that residents still truly embrace.
“There were 300 or so Spaniards expelled [from Belgium last year]. The number is small. But it’s very symbolic,” says Lafuente. “For Europeans, one of the big pillars we got with the EU is the free circulation of people. If you ask Europeans what they most value about the EU, it’s not the unified market nor the austerity policies, but being free to move to another country.”