In a deal that will give the state a 45 percent indirect stake in Bankia, the government will take control of its parent company BFA by converting into equity a 4.5 billion euro loan it had given the financial group previously, the central bank said.
The economy ministry pledged to do all it takes to clean up Bankia, which has more than 30 billion euros of exposure to troubled loans to property developers and repossessed land and buildings.
The government is expected to lend or give Bankia up to 10 billion euros in additional aid, though some bank analysts say it will need more.
Uncertainty over the final cost of the country's banking reform hit the euro, Spanish debt and global stock markets on Wednesday.
If a huge rescue puts Spain's fiscal solvency into question and the country needs international aid, the survival of the euro zone could be at stake.
Since the banking crisis began, Spain has bailed out seven smaller savings banks, but the Bankia rescue is by far the biggest and it comes after a string of other banking reform plans revealed over the past week.
These include moving toxic assets out of some banks and demanding that banks set aside 35 billion euros against loans to the moribund building sector, on top of 54 billion euros the banks are already provisioning.
"We will deepen the process of cleaning up the banks," Prime Minister Mariano Rajoy told a news conference.
Rajoy had promised not to use state funds to rescue the banks, but mounting doubts over Bankia had shaken the euro zone and he did a U-turn.
Rajoy's latest moves are the fourth banking sector overhaul in three years, but investors have yet to be convinced.
The yield on the Spanish 10-year benchmark bond rose to its highest level since the end of November on Wednesday, spiking up to 6.07 percent, close to levels considered unaffordable over the long term..
European shares were down, the U.S. stock market opened lower, and the euro moved close to a recent three-month low versus the dollar, with political turmoil in Greece and the rising costs of fixing Spain's banks deepening fears about the euro zone.
RECOGNISE MORE LOSSES
Bankia will also have to sell off assets and strengthen its management, the government said, even after it named well-known banker Jose Ignacio Goirigolzarri to take over as chief executive.
"These additional measures are geared to enhancing the bank's soundness and restoring full market confidence," the economy ministry said.
Bankia shares fell by as much as 7 percent on Wednesday in anticipation of the state intervention. A 45 percent stake in Bankia was worth 1.9 billion euros ($2.5 billion) at Wednesday's closing share price of 2.13 euros per share.
In further banking reform announcements due on Friday, the government is expected to ask banks to recognize more potential losses, beyond massive write downs on their property exposure.
Some Spanish lenders are unlikely to be able to find the extra funds without public help, raising expectations the government may have to issue more debt to bail them out.
"It depends what's announced, but right now it feels like smoke and mirrors and not the cathartic moment that Spain needs. It looks more like the government has panicked and pushed something out," Ben Levett, an analyst at consultancy 4Cast, said.
Markets have returned their focus to the funding hole at Spain's banks in recent weeks following a negative International Monetary Fund report on the sector and a Standard & Poor's credit rating downgrade.
Spain's banks have around 300 billion euros in total exposure to the building sector, including property seized as collateral, equivalent to around 30 percent of the country's gross domestic product. More than half is problematic.
The country is suffering its second recession in three years and has the highest unemployment rate in the European Union at 24.4 percent, leading more Spaniards to default on their debts and spreading the rot beyond the real estate sector on banks' balance sheets.
The government will demand banks raise provisions to a level equivalent to 30 percent of loans to housebuilders, one source told Reuters, up from the current 7 percent.
"There's no way we can meet these provisions by ourselves - the whole sector would fall into losses," said a source at one savings bank who declined to be named.
Market watchers said Spain should bite the bullet and raise the funds to solve the banking crisis, which has dragged on through two successive governments.
Even injecting the 40 billion to 50 billion euros analysts estimate the banks need to protect themselves against future losses would keep Spain's ratio of public debt to gross domestic product below 100 percent and in line with France and Germany.
"The banking issue has been allowed to fester ... More public cash will raise funding costs for the government but it's worth the risk," said Gilles Moec, an analyst at Deutsche Bank.
($1 = 0.7695 euros)
(Additional reporting by Sonya Dowsett and Tracy Rucinski in Madrid and Steve Slater in London; Writing by Sonya Dowsett; and Fiona Ortiz; Editing by David Stamp and Giles Elgood)
By Carlos Ruano and Jesús Aguado