Image caption The next Spanish government will find itself on the horns of a nasty economic dilemma

Spain's recently-elected Prime Minister, Mariano Rajoy, faces a potentially unsolvable economic dilemma.

He may also face a major financial crisis, if the latest plan to rescue the euro fails.

Only last week Spain was staring into the same financial abyss that had already swallowed Greece, Portugal and the Irish Republic, and was sucking in Italy.

That was before markets came alive with talk of an imminent bailout of Italy by the European Central Bank.

The Spanish government's cost of borrowing money on the financial markets for 10 years - a popular barometer of lender fear - peaked at a rate of 6.7% before falling back on the rumours.

That's close to the level where other eurozone governments turned to their neighbours for a bailout.

In comparison, Germany only has to pay an interest rate of 2.1%.

Off-message

However, Spain's potential descent into the abyss is important for more than the fact that it is - like Italy - an enormous economy that may be too big to rescue.

It is because Spain does not fit the narrative.

Indeed, Spain's story lays bare the fact that the eurozone's problems run far deeper than the issue of excessive borrowing by ill-disciplined governments, which most politicians have focused on.

Until now it has been easy to blame southern Europeans for their economic woes.

Greece couldn't control its spending, and lied about its borrowing statistics.

Portugal also borrowed and spent too much.

Italy, while more frugal, simply has way too much debt - a legacy of government profligacy from way back in the 1970s and 1980s.

But Spain has been a model European. Unlike, say, Germany.

Breaking the rules

When the euro was first conceived in the 1990s, Germany insisted on a "stability pact" to ensure that governments inside the eurozone would keep their finances in order.

Image caption Spain's former Prime Minister Jose Luis Zapatero is only the latest victim of the crisis

Each government promised to keep their total borrowing each year to less than 3% of their GDP - the total output of their economy.

And to join the euro in the first place, they were also supposed to have debts less than 60% of their GDP.

That latter requirement was dropped at the outset, because otherwise Germany itself would have failed to qualify. Its debts, when the euro was created in 1999, were 60.9% of its GDP.

Then the entire stability pact had to be scrapped, as Germany broke the 3% annual borrowing limit every year from 2002 to 2005.

What about Spain? When it joined the euro in 1999, it admittedly also broke the debt rule, with a ratio of 62.3%.

But the Spanish government then proceeded to run a balanced budget on average - that is to say, its borrowing was zero - every year until the eve of the 2008 financial crisis.

And as Spain's economy grew rapidly, its debt ratio fell to a mere 36% of GDP by 2007. Germany's, by contrast, continued to rise.

So, given this record, why are markets telling us that they fear Spain may not repay its debts, while they think Germany's debts are the safest bet within the eurozone?

It doesn't seem entirely fair.

Boom and bust

The reason is that Spain is facing an impossible economic dilemma.

When Spain joined the euro, interest rates fell to the much lower levels typical in Germany.

While the Spanish government resisted the lure of cheap loans, most ordinary Spaniards did not.

The country experienced a long boom, underpinned by a housing bubble, as Spanish households took on bigger and bigger mortgages.

House prices rose 44% from 2004 to 2008, at the tail end of a housing boom, according to ministry of housing data. Since the bubble burst, they have fallen 17%.

During the boom years, Spaniards earned more and spent more.

That helped to flatter the government's finances. More economic activity means more tax revenues.

But it also helped push Spanish wages up to uncompetitive levels.

Unit labour costs in Spain - a measure of the cost of employing an average Spaniard - rose 36% from the euro's creation in 1999 until the end of 2008.

Contrast that with Germany, where unit labour costs rose just 3% over the same period.

Shrunken economy

Now Spain is bust.

Its workers are overpriced compared with German workers. Its construction sector - bloated during the building boom - has collapsed.

Households are cutting their spending as they struggle to repay their debts. And unemployment - always high in Spain - has shot up to 21.5% of the workforce.

The economy, which grew 3.7% per year on average from the euro's foundation until the end of 2007, has since shrunk at an annual rate of 1%.

So, although the Spanish government still has relatively little existing debts, it is now having to borrow like crazy to fill the gap left by the jump in unemployment benefits and collapse in tax revenues during the downturn.

And the government may also have to throw a lot more money at its banks, which are looking very exposed to the housing collapse thanks to all the mortgages they have lent.

All of which makes financial markets nervous about lending to Spain.

Inflate or devalue

But here is the nasty dilemma facing the incoming Spanish government.

To get out of its economic hole, Spanish workers need to regain their competitive edge. That will boost demand for Spanish output, and help the economy grow.

And a growing economy is one that can support a heavy debt load.

But how will they do this?

If workers agree to large wage cuts - which is unlikely unless unemployment rises even higher - they will find their mortgages even harder to repay.

So most Spaniards would spend less, and many might be unable to repay the banks, all of which would make the economic downturn even more severe.

On the other hand, if Spanish workers increase their wages, they will become even less competitive and lose even more business to their eurozone competitors.

There are two possible solutions.

First, German wages could rise much more quickly. That means Spaniards could regain a price advantage without having to take a wage cut.

To achieve this, the European Central Bank would probably need to raise its inflation target to a level higher than the current 2% rate. That is an absolute no-no at the ECB, particularly among its German members.

The alternative is that Spain could leave the euro and devalue the newly recreated peseta. Spanish wages would fall with the peseta's value, but so would their debts.

Leaving the euro would also largely eliminate the risk of the Spanish government running out of money, because the Spanish central bank would be free to bail it out - something the ECB has refused to do.

However, it is precisely the possibility of a break-up of the euro that now has financial markets most worried of all.