Image caption Bankia is the largest of the four being restructured

The European Commission has approved the Spanish government's plans to restructure four troubled banks.

Bankia, NCG and Catalunya Banc must cut their loans and investments by over 60% in the next five years, shut half their branches and shed thousands of staff.

A fourth bank that was in the worst shape, Banco de Valencia, is to be sold to the privately owned Caixa Bank.

The agreement means the banks will now get almost 40bn euros (£32bn; $52bn) in loans from eurozone bailout funds.

"Our objective is to restore the viability of banks receiving aid so that they are able to function without public support in the future," the European Competition Commissioner Joaquin Almunia said.

All four were nationalised by Madrid after suffering heavy losses on loans to homebuyers and property developers.

Bankia, the largest of the four, announced on Wednesday that it would lay off 6,000 employees - 28% of its workforce - and shut 39% of its branches.

Trading in shares of Bankia and Banco de Valencia were suspended for the day on the Madrid stock exchange, to give investors time to digest the details of the announcements.

Shrinking banks

The Commission's approval opens the way for Spain's government to draw 37bn euros from a 100bn-euro loan facility made available by the eurozone's bailout fund specifically for the purpose of cleaning up the country's banks.

Of that money, 18bn euros will go to Bankia, 9bn euros to Catalunya Banc, 5.5bn euros to NCG and 4.5bn euros to Banco de Valencia.

Shrinking their size will help the banks repay rescue loans they have received from the European Central Bank, via the Spanish central bank.

They will do this in part by selling their most problematic loans to Sareb - the Spanish government's "bad bank", which will be responsible for seeking to recover as much of their value as possible in order to mitigate the cost to taxpayers of rescuing the banks.

Bankia - which lost 3bn euros last year and expects to lose 19bn euros this year - said it would shrink itself by some 50bn euros by selling assets to Sareb, and also by cutting back on lending and by selling off investments in Spanish industry, including a 12% stake in International Airlines Group, the owner of Spanish national airline Iberia and of British Airways.

The banks will no longer be allowed to lend to property developers, and must refocus their business on loans to Spanish households and to small and medium-sized businesses.

During the restructuring period, the banks will be banned from acquiring other companies, and employee pay at the banks will be capped.

The three banks remaining in government ownership are meant to be sold off by Madrid before the end of the five-year period.

Ordinary investors

According to the European Commission, some 10bn euros of the restructuring cost must be borne by investors in the banks.

Image caption Ordinary Spaniards who were sold preference shares by their banks now face significant losses

These investors are controversially expected to include many ordinary Spaniards, particularly older investors, to whom their banks sold preferred shares - a high-risk form of bank debt - as a savings product.

They are set to lose between 10% and 50% of the value of their investments.

The banks have been banned from making interest payments to these investors until the amount of their losses has been finalised.

Many of Spain's other banks have also been hit by heavy losses on loans they made during last decade's property bubble.

Last week, the Spanish central bank revealed that total losses at Spanish lenders had reached an all-time high of 182bn euros in September, equivalent to 17.4% of Spain's annual economic output.

Falling retail sales

In June, the International Monetary Fund reported on the Spanish banking sector, noting that dozens of troubled banks had been bought up by supposedly stronger rivals since the financial crisis began in 2008, reducing the total number of banks from 45 to 11.

Bankia, the biggest of the four banks, was created in 2010 from the government-sponsored merger of seven troubled regional savings banks - a merger that did not stop Bankia itself from needing to be rescued earlier this year.

The consolidation continues with the sale to Caixa Bank of Banco de Valencia, which was deemed to be the worst shape of the four banks and therefore incapable of surviving on its own.

On Wednesday, the IMF reported that Spain remained on track with its reforms. But it said that risks for the country's economy remained high, and Spain was set to remain in recession in 2013.

The economy has been back in recession for over a year already.

The IMF report also noted that two further groups of Spanish banks still need to clean up their balance sheets: There are four small banks who need state aid from the government, but not full nationalisation, while two medium-sized banks have until June to raise money from the private sector without the government's help.

Almost all of Spain's banks have cut back their lending, as they try to restore their health, with the result that the entire Spanish economy is suffering from a credit crunch, alongside a property collapse and government austerity measures.

The IMF identified this process of bank "deleveraging" as the key risk facing the Spanish economy.

Meanwhile, earlier on Wednesday, official data revealed that retail sales in Spain fell by 9.7% in October from a year earlier.

The steep fall was actually better than markets had expected, and an improvement on the 11% year-on-year fall seen in September - the worst drop since records began.

The fall in sales is due in large part to a three-percentage-point increase in VAT at the end of the summer.