Blighted by recession and tottering on the edge of a sovereign bailout, Spain is about to pay the price of joining the club of richest nations in the European Union.
For the first time, Madrid may have to pay more into the bloc than it receives, a dramatic change from 10 years ago when it was the biggest recipient.
It is an unfortunate paradox at a time of deep crisis.
Spain is ready to accept such a change so long as it is gradual, said a diplomatic source ahead of a November 22-23 European Union summit on the budget for 2014-20.
At the same time Madrid wants to keep receiving EU funds for worse-off regions such as Andalusia and Galicia and agricultural subsidies, of which it is the second-largest recipient after France, the source said.
But early indications are not promising.
Spain could lose 20 billion euros ($25 billion) in the next budget, with 30 percent less for the regions and 17 percent less for farmers, said a European source.
"Spain is one of the countries that has benefited the most from its entry into the European Union," said Rolf Campos, analyst at the IESE Business School in Madrid.
That reinforces broad Spanish support for the bloc, which it joined in 1986.
"People have a very good opinion of the euro and they associate the European Union with something positive," Campos said.
But it was also important to remember the outlook, the analyst said, with forecasts tipping a combined three percent decline in Spanish economic output over the next two years.
"So Spain will become poor again in the heart of Europe," he said.
The scale of the European Union's support for the Spanish economy is easy to see, said Mario Kolling, a researcher at the Real Elcano institute.
"You just have to look at its high-speed train network, jointly financed in large part by the European Union," he said. Spain has the second longest high speed rail network in the world.
"In Spain, Europe has always been seen as a solution, as a path to modernisation of the country," Kolling said.
Spain appreciated not only European funds but also "the rehabilitation it represents" after the country's return to democracy following the death in 1975 of General Francisco Franco, he said.
With the arrival of new European Union members such as Bulgaria and Romania, Spain has become one of the richer states by comparison.
And after managing to hold on to its status as a net beneficiary over the 2007-2013 period, Spain will "very likely" become a net contributor over the next 2014-2020 cycle, Kolling predicted.
But the upgrade, which places Spain in the same ranks as Germany, France or Britain, "is in some ways bad news," he conceded.
Spain may hope that its elevated position could give it a bit more heft in European Union discussions.
But "the country's economic situation and the possibility of a financial bailout continue to limit its room for manoeuvre and Spain's weight in the EU," Kolling said.
In fact, Spain is still struggling to pick itself up after a 2008 property crash, which wrecked bank balance sheets, sent debts soaring and left one in four workers unemployed.
The irony is that it will be paying money to the same partners it may soon be reaching out to for aid.
Spain's eurozone's partners agreed in June this year to extend an emergency rescue loan of up to 100 billion euros ($129 billion) to help its stricken banks.
Now, the Spanish government is pondering whether to apply to the eurozone's bailout fund for a sovereign rescue, which would open the way for the European Central Bank to buy the country's bonds and curb its borrowing costs.