MADRID – The Spanish government’s decision to take control of the country’s fourth-largest bank highlights the problem gripping the nation’s financial system. Banks are taking huge losses on real estate loans that have soured, but the deeper the government gets involved in providing aid, the greater the risk it will need an international bailout.

Financial stocks in Madrid soared Thursday, a day after the government said it would take a 45 percent controlling stake in Bankia SA, which has the highest exposure to bad property loans of all Spanish banks following a crash in the construction sector that started in 2008.

But because the government – already strapped for cash – will finance the takeover, investors continued to worry that the country might eventually need rescue aid itself. Spain’s sovereign borrowing rates remained uncomfortably high on Thursday, suggesting traders are wary of its financial future.

Because the fates of Spain’s banking sector and its government are so closely linked, analysts say a new approach – possibly with financial aid from abroad – may be needed.

“Once again the government has reacted late and badly,” said Javier Flores, an analyst in Spain with Asinver investment group.

“There is something that everyone knows, it’s talked about privately but no one wants to admit to in public,” said Flores. “Spain’s banking sector is sitting on a huge toxic asset problem that is not worth what it says on the banks’ accounts.”

Spanish financial stocks have been battered in recent months on growing worries that their bad real estate investments will hurt their earnings for a long time or even cause some of the weaker lenders – such as the regional cajas – to collapse.

The Bank of Spain estimates that banks are sitting on some $233 billion in assets that could cause them losses.

In the short-run, the government’s nationalization of Bankia eliminates the risk it could collapse, possibly causing a series of bank failures as it defaults on money it owes to other Spanish banks. That would create a credit crunch similar to the one that paralyzed global markets in 2008.

Analysts warn Bankia’s rescue cannot be enough, that the wider sector needs more help, though the government has little financial firepower left to do so.

Concern that the Spanish government’s finances may be overwhelmed by the cost of rescuing banks has pushed investors to ask for high interest rates to lend to the country. Those worries persisted on Thursday, with the benchmark 10-year bond yield at the perilously high level of near 6 percent. Bond yields indicate the rate the government borrows at when it taps financial markets. Rates of above 7 percent are seen as unsustainable in the long-run.