By Steve Kingstone
BBC News, Madrid
On the northern outskirts of Madrid, the Tres Cantos railway station is getting a makeover.
Under a fierce midday sun, immigrant labourers from North Africa, Latin America and Eastern Europe shift huge concrete slabs into place on the platform, and scatter fresh layers of shingle between the rails and sleepers.
For many working on the railway, this represents their last job
This back-breaking work pays €1,200 (£950) per month, and everyone is making the most of it.
With the construction industry in dire trouble, their Spanish boss has no other projects in the pipeline, and the entire workforce will be laid off when this job ends.
So, any takers for the government's new offer to unemployed immigrants?
If they volunteer to go back to their home countries and not return to Spain for three years, foreigners will qualify for lump-sum benefit payments, typically worth around €18,000 (£14,200).
The scheme applies to the citizens of 19 non-EU countries which share social security agreements with Spain.
"If someone offered me that cash now I'd go," says Patrick, from Equatorial Guinea. "Back home, it would go further; I could invest it," he adds.
Guillermo, from the Dominican Republic, warns that: "if the economy carries on like this, we'll all have to leave". But given a choice, he would rather stay. "I now consider myself Spanish," he grins.
In the space of barely a decade, Spain's immigrant population has leapt by an astonishing 800%, and cheap immigrant labour was a vital factor in the construction-led economic boom.
As long as there was work to go round, Spain mostly avoided the kind of immigration-related tensions witnessed in other European countries.
Today, however, with an EU-high unemployment rate of 10.7%, the picture looks very different.
"Immigrants were seen by everyone as helping," explains Pedro Schwarz, an economist.
"They took jobs in construction - boosting growth and keeping wages down. But today, with the jobless total rising, some Spanish-born citizens are complaining that the new immigrants are beginning to hog the unemployment benefits."
For the time being, the 2.1 million foreigners registered for Spanish social security are net contributors to the system - paying in more than they receive.
But, over the past 12 months, the number of immigrants claiming unemployment benefit has surged by 81%, to 178,230 in July 2008.
"What we're trying to do is link immigration to the labour market," says Celestino Corbacho, Spain's minister for work and immigration.
"The forecasts say it'll take two or three years for the economy to recover, so we think it's good to offer people possibilities.
"If someone is entitled to $15,000 (£8,000), that's going to create more opportunities in their home country than here in Spain."
"Thank you and goodbye"
Under the new scheme, scheduled for launch in September, participating immigrants would receive two years worth of up-front unemployment benefits - 40% when they volunteer for the scheme in Spain, the rest on arrival back in their country of origin.
To qualify, they would have to surrender their Spanish work and residence papers for the duration of the deal.
The government insists this is merely a common sense response to Spain's undeniable economic problems, but immigrant welfare groups view the policy with suspicion.
"I feel that we've been used," complains Washington Tobar of the Hispano-Ecuadorean Foundation in Madrid.
"When they needed cheap labour, the doors opened. And now they don't need us, they just say 'thank you and goodbye' - and expect us to go back to our own countries."
In a modest apartment in Madrid's La Latina district, 42-year-old Leonardo Ramirez prepares lunch for his two children.
A marketing graduate in his native Ecuador, he paid his way here through construction, until the work dried up a year ago.
Now renting out a spare room to help pay his mortgage, Leonardo is one of 100,000 unemployed foreigners whom the government hopes immediately to tempt with its offer. But he is far from keen.
"Even $20,000 or $30,000 isn't that much money, in terms of capital to invest back home," he explains.
"They are people who'll have to buy a house, and children's schooling is expensive. Also, immigrant families are integrated here - they don't want to start all over again."
Outside, on Leonardo's housing estate, immigrant children play football, while Latino pop blares out from several apartments.
Spain, thanks to immigration, is a very different country from a decade ago
This new Spain is unrecognisable from the country of 10 years ago, and the government is controversially trying to turn back the clock.
But Mr Corbacho denies that Spain is ungrateful for the contribution made by immigrants, or that foreigners are being made scapegoats for the country's economic woes.
"Immigration is not a problem, it's a phenomenon," says Mr Corbacho.
"And phenomena are never neutral - they change a lot of things and create new challenges. Our challenge is to manage this phenomenon, so that our diverse, multicultural society avoids conflict in the future," he says.
It is a radical approach to immigration from a socialist government which appeared to run shy of the issue in the lead-up to its election victory in March.
Now, the politicians hope - quite literally - to make the problem go away. And other EU governments, facing similar challenges, will be closely monitoring the Spanish scheme's progress.