WITH unforeseen suddenness, a new political era has begun in Spain. Having ousted Mariano Rajoy, the long-serving conservative prime minister, in a parliamentary censure by 180 votes to 169, this week Pedro Sánchez, the Socialist leader, formed a new government. It will be weak, commanding an even smaller minority in Congress than its predecessor, but not necessarily brief: a general election may not come for at least a year.

Mr Sánchez, a 46-year-old economist, has appointed a cabinet that mixes old faces from previous Socialist administrations with new figures, several from regional governments that his party runs. Its make-up sends three messages. Some are designed to rebut the charge by Mr Rajoy’s People’s Party that the new prime minister is a hostage to the Catalan nationalists and Podemos, a populist leftist party, whose parliamentary votes helped to bring him to office.

The first message is stability and commitment to Europe. Mr Sánchez has made a virtue of his limited support by pledging to stick to Mr Rajoy’s budget (and its target of cutting the fiscal deficit to 2.3% of GDP). This would “guarantee the governability of our country at an extraordinarily complex moment”, he said in Congress. Raising more than a few socialist eyebrows, he named Nadia Calviño, currently the European Commission’s director-general for budgets, as his economy minister.

The new prime minister has not offered to repeal Mr Rajoy’s liberalising labour-market reform, as the unions would like. This reform has helped to spur a rapid fall in unemployment during the past four years of strong economic recovery from the euro crisis. All this means that the political shake-up has caused scarcely a ripple among investors, who are more concerned with Italy’s political crisis.

Second, the new foreign minister, Josep Borrell, is an experienced former minister and president of the European Parliament, and also a Catalan. Mr Borrell campaigned against the drive for independence by Carles Puigdemont, Catalonia’s former regional president. His appointment signals that the new government will uphold the constitution (which bars secession) and will be more active in making that case abroad.

Third, in a country where feminism is gaining ground, 11 of the new cabinet’s 17 members are women. It is a cabinet “in the image of Spain”, Mr Sánchez said, committed to social and gender equality as well as economic modernisation, with science and innovation as motors.

Such gestures will be an important part of Mr Sánchez’s rule, because his scope for bringing about radical change is small. His Socialists, who have only 84 of the 350 seats in Congress, will govern alone. Mr Rajoy’s PP had 134 seats and could count on Ciudadanos, a liberal party, with 32.

The ghost of the past

Before calling an election—due in the summer of 2020 at the latest—Mr Sánchez promises to roll back several measures (such as restrictions on freedom of assembly) imposed by the PP when it had a majority, and to which most of the current parliament is opposed. He promised a law requiring equal pay for equal work for women and men, and more efforts to help the long-term unemployed.

Above all, Mr Sánchez brings a breath of fresh air. Polls show that the country had tired of Mr Rajoy. He doggedly hauled Spain out of a deep economic slump with reforms of the broken financial system as well as of the labour market. But the constitutional crisis over Catalonia took its toll on his government. Above all, Mr Rajoy failed to grapple with, investigate or apologise for a steady stream of corruption cases and scandals involving his party.

On May 24th a court found that the PP had run an illegal financing scheme, and that Mr Rajoy’s evidence denying this lacked credibility. Since he had often highlighted, in the Catalan context, that Spain’s judiciary is independent and the rule of law paramount, that made his position untenable, as Mr Sánchez quickly grasped. Mr Rajoy, a great survivor whose stolid appearance hides sharp political instincts, had been outwitted at last. This week, in a tearful farewell, he resigned as the PP’s leader, a post he has held for the past 15 years.

Mr Sánchez is nothing if not daring. Just 19 months ago his political career seemed over, after he was deposed as leader of the Socialist party by its regional barons. They had turned against him following two election defeats, and because he was prolonging a parliamentary deadlock by refusing to allow the formation of Mr Rajoy’s minority government. His response was to get into his ancient Peugeot and travel round the country, rallying the party faithful. In May 2017 he got his revenge by unexpectedly winning back his old job in a party primary election.

His position is not without risks. The PP still controls the Senate; it thinks it has been unfairly bundled out of office without an election and promises the incoming government a rough ride. Mr Sánchez said he would try to get a more generous budget passed for next year, but that depends on maintaining his heterogenous base of support. Nevertheless, it is hard to unseat a Spanish prime minister, since the constitution requires a parliamentary majority for an alternative. Mr Rajoy was the first to suffer this fate in 40 years of restored democracy. If necessary, a government can roll over a budget for a second year.

The biggest challenge remains Catalonia. Mr Sánchez supported Mr Rajoy’s imposition of direct rule after Mr Puigdemont’s unilateral declaration of independence. This week that was lifted as the separatists formed a new government. The prime minister said he wants dialogue, as did Quim Torra, his Catalan counterpart. Mr Sánchez can try to lower the tension, for example by appointing a less militant attorney-general. But creating common ground will take time.

The risk for Mr Sánchez is that his government is seen as a last gasp of the old political duopoly, discredited during the economic crisis as well as by corruption (which has spattered the Socialists, too). The unspoken reason for the success of the censure was that Ciudadanos, riding high in the polls, is the only party wanting an immediate general election; the rest want to avoid one. The Socialists are becalmed at around 20%. Mr Sánchez hopes he will be able to lift that number before going to the country. It is his biggest battle yet.