The Spanish government has promised to bail out the country's banks through the use of public funds as the banks continue to struggle with the collapse of the housing market.

Prime Minister Mariano Rajoy said Monday the government was ready to step in to save banks, starting with Spain's fourth-largest, Bankia, which was first in line for state aid. The government had previously ruled out pumping funds into ailing banks.

If it was necessary to reactivate credit, to save the Spanish financial system, I wouldn't rule out injecting public funds, like all European countries have done, Rajoy told Spanish radio.

The announcement comes only days after elections in France and Greece returned leftist and extremist candidates opposed to austerity measures into power, further undermining efforts to tackle the continentwide debt crisis.

The Spanish announcement prompted the resignation of Bankia head and former IMF managing director Rodrigo Rato.

The Finance Ministry is now preparing to refinance the bank and draft legislation that paves the way to recapitalize others in a similar situation.

Regarding Bankia, Javier Diaz-Gimenez, an economics professor at IESE business school in Madrid, told Bloomberg: In some way this is really all to the good because it means progress is being made. Whatever way they choose to take the Bankia situation forward, there's now going to be a technical guy in charge and not a politician.

The bailout move comes after Spain's unemployment rate jumped to more than 24 percent last month, the highest level of any nation in the 17-country euro zone.

Also last month, the credit ratings agency Standard & Poor's downgraded the country's debt rating from A to BBB+ (the same level as Italy), citing a worsening budget deficit, worries over the banking system and poor economic prospects.

The double-blow to recovery hopes followed the Bank of Spain's confirmation that the country had entered a technical recession in April.

Investors, initially spooked by election results in France and Greece, quickly regained confidence yesterday, with shares and the euro recouping initial losses.

But while markets could stomach the election of Socialist Francois Hollande to the French presidency, the uncertain situation in Greece -- where no single party, or even two of them, can form a government -- has increased speculation the country may be forced out of the euro zone.