Euro zone finance ministers approved an agreement on Friday to lend up to 100 billion euros ($123 billion) to Spain so it can recapitalise its banks, but the exact size of the loan will probably only be determined in September.
In a conference call, ministers signed off on a lengthy memorandum of understanding with Spain spelling out the terms of the aid, which will be fully disbursed by the end of 2013.
But before Spain can decide exactly how much money it needs, it must see the results of in-depth audits of its banking sector, which is riddled with bad property loans.
Speaking at a news conference after the conference call, Luxembourg's Finance Minister Luc Frieden said the ministers had given the go-ahead.
"We have formalised what we discussed in the past two Eurogroup meetings. We have formally approved the memorandum that lays out the conditions under which Spain can be lent money for the recapitalisation of its banks," Frieden told reporters.
"The approval of all 17 ministers is there, and that means that the programme can continue. Money will not flow immediately, because work on the analysis of the specific banks is ongoing."
The bank rescue, and fresh austerity measures and looser fiscal targets agreed with Madrid, are aimed at avoiding a full sovereign bailout that the euro zone can barely afford.
There are signs of growing discontent at the economic pain being heaped on the Spanish public. Hundreds of thousands of Spaniards marched against the centre-right government's latest measures on Thursday evening, following more than a week of demonstrations across the country.
Parliament approved on Thursday a package of 65 billion euros ($80 billion) of spending cuts and tax hikes which are likely to deepen the recession already gripping Spain.
Under the bailout memorandum, 14 banking groups that make up about 90 percent of Spain's banking system will be tested for their recapitalisation needs in a review due to be completed by the second half of September.
Madrid expects 30 billion euros in a first tranche of money that will be available immediately for state-rescued banks that urgently need funds.
An independent audit from consultancy firms Oliver Wyman and Roland Berger, published on June 21, showed the banking sector needed up to 62 billion euros in total.
But a second, more detailed audit, as well as new stress tests, will help determine precisely how much each bank needs and in what form - loans or cash.
Spain's three biggest banks - Banco Santander, BBVA and Caixabank - would not need extra capital even in a stressed scenario, the independent audit said.
It also said immediate problems were limited to four banks: Bankia, and CatalunyaCaixa, NovaGalicia and Banco de Valencia, the last three of which have been nationalised.
That leaves seven banking groups in the spotlight: Sabadell , Popular, Ibercaja-Caja3-Liberbank, Unicaja-CEISS, Kutxabank, Banco Mare Nostrum and Bankinter.
FOCUS ON SAVINGS BANKS
The money for the capital will be provided by the euro zone's temporary rescue scheme, the European Financial Stability Facility (EFSF), a 440 billion euro fund set up in 2010 that has about 250 billion euros left, not counting the money for Spain.
The EFSF has already been used to bail out Greece, Ireland and Portugal, making Spain the fourth euro zone nation to receive emergency aid in the 2-1/2-year-old crisis.
The EFSF loans to Madrid will have an average maturity of 12.5 years and a maximum of 15 years, with interest rates of between 3 percent and 4 percent.
Once the permanent European Stability Mechanism (ESM) rescue fund is operational, probably in September, it will take over the job of funding Spain's programme.
All Spain's banks will have to increase their core capital ratios to 9 percent by the end of 2012 and keep them at this level until the end of 2014. However, the government will review by December the requirements for setting aside capital to cover losses on real estate assets.
There will be a special focus on savings banks, or "cajas", which had close links with local governments and were responsible for much of the unsustainable lending over the last decade, and their governance structure will be reviewed.
According to the memoranudm, Spanish authorities will prepare by the end of November a new law to reduce the stakes that savings banks have in commercial lenders to non-controlling levels. Banks that are controlled by the cajas and receive state aid would become listed companies.
The measure is mostly symbolic, applying only to a handful of banks representing a small share of Spain's banking system, but a failure to implement it could worry investors.
The document also says holders of hybrid capital and subordinated debt in state-rescued banks will have to take a haircut on their investments in order to minimise the cost to taxpayers of the restructuring.
Hundreds of thousands of small shareholders who bought instruments such as preference shares are likely to be affected.
The first injection of capital into banks not already rescued by the state and unable to raise capital by themselves can be expected by October, after reviews by the Spanish government and the European Commission.