Spain has been held up to other euro zone countries as an example of the benefits of structural reform. That’s fair enough, up to a point. The conservative government’s bank rescues and labour reform have stabilised the financial system and improved competitiveness. The economy is expected to grow 1.2 percent this year and 1.7 percent next year by the European Commission.

But the country is troubled, as I discovered after spending several days in Madrid and Barcelona last week. The unemployment rate may be falling but it is expected to end next year at an eye-watering 23.5 percent. Corruption scandals embroiling politicians from all the traditional governing parties are popping out of the woodwork. And government debt is still climbing and expected to exceed 100 percent of GDP next year.

Meanwhile, many Catalans are campaigning for independence. At the weekend, Barcelona held an unofficial vote on quitting Spain. Although this became something of a theatrical exercise after Madrid stopped it having a referendum, the campaign will go on until the people are given a choice over whether to stay in Spain or leave it.

The next major move in Catalonia is likely to be regional elections, which have to be held within two years but may be brought forward. Esquerra Republicana de Catalunya, a radical nationalist group, is almost certain to become the largest party, supplanting the moderate nationalists who currently run the government.

Esquerra would want to declare independence unilaterally. Such a move could have dramatic and immediate consequences. It would probably lead to a run on banks in Catalonia and capital controls, as people tried to take out their deposits; as well as a default by the regional government, if Madrid stopped sending it money. Given that this would be economically disastrous, Esquerra probably wouldn’t be able to secure the support of the moderate nationalists for a unilateral declaration of independence. But the Catalan issue would still be a running sore.

The discredited political class is at a loss over what to do about all these problems. The government’s initial reforming zeal has faded into history as Mariano Rajoy, the prime minister, prepares for a general election which has to be held by early 2016. The last initiative, a tax reform announced in the summer, ended up as a damp squib.

The opposition socialist party has a young new leader in Pedro Sanchez, who is not tarred by corruption scandals or the policy errors of his predecessors. However, he is struggling to come up with a coherent economic policy. His most notable idea is to roll back the labour reform, which has been the current government’s most successful policy.

This has left open a huge gap in the market for Podemos, a left-wing populist party. It is now leading in the opinion polls even though it didn’t exist a year ago. Podemos, the Spanish for “we can,” wants to clean up politics, which is good. But its leaders sympathise with Venezuelan-style Chavismo: it wants to cut the retirement age to 60, audit the country’s debt before writing part of it off, and guarantee everybody a minimum income. If such a programme ever became policy, Spain would be heading for default and exit from the euro zone.

In fact, what the country needs is a second wave of reforms. There should be another dose of labour reform, as those in permanent jobs still have excessive privileges with the result that most new jobs are short-term contracts. Taxes on labour should be cut and replaced with taxes on spending, to encourage more job creation. And court procedures need to be simplified to speed up justice and so encourage investment.

Unfortunately, the prognosis is not good. The next general election is most unlikely to produce an overall majority for any of the three leading parties – the conservatives, socialists or Podemos. But they won’t be able to cut a deal with the Catalan parties, unless they offer a referendum; and the other parliamentary groups are too small to count.

As a result, two of the big three parties will probably need to club together to get a majority. But this will be as awkward as elephants and rhinos mating. A socialist-Podemos alliance is possible. Although neither party would want to join forces, their supporters might want them to. The snag is that the economic policies that would then emerge would be deeply unappealing.

A “grand coalition” between the conservatives and the socialists would be the best bet. In such a situation, Rajoy might have to step down as prime minister to make way for either somebody from his own party such as his deputy Soraya Saenz de Santamaria or for the socialists’ Sanchez.

Such a coalition would also be the best way of resolving the Catalan situation. Before Catalonia could be given a vote, Spain’s constitution would have to be changed – and that would require a super-majority in parliament as well as a referendum of all the Spanish people.

But the socialists and conservatives will be reluctant to form a pact. This is not just because of their traditional rivalry. A grand coalition could play into Podemos’ hands, seemingly validating its script that the two traditional parties are as bad as each other. The upstart party might then be well placed to take power in the following general election, in much the same way that Greece’s radical-left Syriza party looks set to win that country’s next elections after the conservatives and socialists formed a grand coalition.