ONLY FOUR YEARS AGO, when Spain’s property market was still booming, some bank branches could easily have been mistaken for real estate brokerages. The spacious lobby of the Banco Bilbao Vizcaya Argentaria branch on Calle de Alcalá in the heart of Madrid exhibited a large model of vacation and retirement apartment towers that Spain’s second-largest bank had financed on the sunny Mediterranean coast and was filling with BBVA mortgage holders.

Today, Spanish banks have banished development projects from their lobbies. Getting them off their balance sheets is proving to be far more difficult. The collapse of the property market has left the coast littered with half-finished condominium high-rises and turned many of the country’s lenders, especially savings banks known as cajas, into zombie banks. The banking system has extended more than €300 billion ($400 billion) in loans—roughly equivalent to one third of the country’s gross domestic product—to real estate developers, many of which are now deep underwater if not bankrupt.

The banks’ woes now threaten to undermine the wider Spanish economy. Mounting loan losses have slowed the flow of credit, brought growth to a standstill and sent joblessness rocketing to 22.8 percent, the highest rate in the 17-country euro zone. The economic slowdown, in turn, has bloated the budget deficit and sent yields on government bonds soaring. The declining health of banks and the sovereign are closely intertwined here, as in much of Europe, with the government having already injected more than €17 billion in capital into ailing cajas and seized five lenders....