After the PSOE called for a vote of no-confidence last month, it had been widely expected that Ciudadanos — an upstart center-right party with some populist energy behind it — would take power if Rajoy was ousted after 29 PP affiliates were convicted on corruption charges . A series of late-breaking moves by politicians across the ideological spectrum in Spain produced a very different result, the product of developments in several long-simmering tensions within the country, including Catalan independence. Now Sánchez, 46, and the PSOE will need to cobble together a government amid one of the most remarkable recent developments in European politics. Having been the party in power in the midst of Europe’s debt crisis, they may also have to rebuild political capital lost after they carried out painful austerity measures — what ultimately lost them the government in 2011.

After People’s Party Prime Minister Mariano Rajoy received a vote of no-confidence early Friday, and parliament turned instead to PSOE, the Spanish acronym for the social democratic party, forces on the left and right are still reeling from the shock.

After a raucous several days in parliament, Spain, much to the surprise of the Spanish Socialist Workers’ Party, is now helmed by its leader Pedro Sánchez.

What just happened?

No one expected this three days ago. For me what explains it is that Ciudadanos totally overplayed their hand. They were leading in the polls and wanted quick elections. They take a strong line on Spanish nationalism, which means that both the Basque and Catalan nationalist parties were worried about them forming government. They also have fairly conventional neoliberal economic policies, meaning the left parties don’t support them either.

By them announcing that they didn’t support Rajoy, they misjudged the situation entirely. It was better to have PSOE in that scenario than a corrupt PP or an immediate election that would put Ciudadanos in power. First the left-leaning Catalan separatists announced they’d support PSOE, then there was a power struggle among the right-wing Catalan nationalists, and the moderates won out over the ultra-ists. The moderates said it would be better to have a government that in theory is more open to dialogue on the national question, which PSOE is. The Basque nationalist party (PNV) had just negotiated a very favorable budget deal with the PP and didn’t want changes to that because it secured a big investment in the Basque country. They were very worried about a Ciudadanos government because that party has a strong line against Basque fiscal privilege and the region’s separate financing regime.

Last week, it became explicit that Sánchez had a majority. While the confidence discussions were taking place, Rajoy and his team went and stayed at the same restaurant from 2 p.m. until 10 p.m., in what was seen as a sign of disrespect to Spain’s democratic institutions.

How do you expect the Sánchez government to solidify?

PSOE will form a government in the context of a very fragmented parliament. Battle lines that existed between the right and left are going to be really sharpened. Sánchez is going to have to navigate a context of uncertainty, and we’ll see what he can do in terms of agenda-setting and pushing forward a progressive program.

Personally, I would be surprised if there were a coalition government with Podemos and PSOE. What is to be gained? On the right, there’s a struggle between Ciudadanos and the PP. On the left, it’s between PSOE and Podemos. The parties within both the left and right are frenemies right now, and I’m not sure you give your frenemies cabinet positions.

I don’t think establishing a permanent working majority is one of the main objectives here, and policies will probably largely hinge on Ciudadanos in terms of parliamentary strategy. Podemos has made an important contribution to the regeneration of Spain’s democratic institutions. They’re not in a stronger position [in the] parliament after today to extract anything. But they’re definitely in a stronger position to put issues on the table, like freedom of expression. Yesterday and today were a good day for a thaw of relationships on the left. It clarifies what should have been the obvious, which is that the main cleavage in Spanish politics is between right and left.

I think PSOE are going to have a minority government. From the looks of it, the PP are going to be full-on opposing anything that PSOE puts forward. Ciudadanos could be sort of a swing vote, though wouldn’t participate in any three-way deal with PSOE and Podemos. They’re a center-right liberal party, and it’s going to be hard to bring them and Podemos together to do deals on anything related to the economy. In terms of a positive program, PSOE could push a feminist agenda or a climate agenda, and to repeal the PP’s most draconian laws against public expression. The goal will be to resist.

What happens next?

Sánchez may be on the verge of meeting with the King right now. First, he’ll have to make the cabinet, and then staff out his administration. PSOE is a party of government; there is a lot of talent being held in reserve. This has all been so quick that the political system is still reeling. The opposition’s goal will be to make his stay in office as short as possible, and ensure he doesn’t stay past next year’s local and regional elections at the latest.

This is the first time in Spanish history that a prime minister has been removed in this way. That means you don’t just need the votes to topple a guy. You need the votes to bring in a new one, too. Now they have to figure out how to set a different agenda than the one that has been in place for the last seven years, which I suspect will be premised on economic stability, anti-corruption, social stability, and dialogue on the national question — the same things we were pushing for before.

On the fiscal front, it’s a bit of a bizarre situation. Sánchez pledged to preserve the budget that was passed a few weeks ago because it was key to gaining support from the Basque nationalists. It’s the most Keynesian budget in Europe, simultaneously implementing tax cuts and spending increases. It’s bad on the deficit front, which is relevant to the European question playing out in Italy right now.

That means we are inheriting a budget that has the wrong priorities, but that should have a positive impact on the economy. The PP’s pre-election budget is now our pre-election budget, in the sense that it stimulates the economy from the demand side. It’s highly unlikely at this point that we could undo the tax cut and invest in anti-poverty measures, but it’s too soon to know.

How will PSOE now have to deal with the national question?

So far as I know, they won with the Basque and Catalan nationalists without promising anything in return, beyond just being more open to dialogue. PSOE has always been more aware than other parties about the plural nature of Spain.

There are three relevant factors on Catalan nationalism. There’s the republican left, who after the last regional elections realized that the unilateral independence path was a dead end and have been trying to return to dialogue. Then there are two factions of right nationalists. PDCAT, heirs to the old Convergencia, are part of the coalition Junts per Catalunya (JxC), who are also in favor of dialogue. And then there’s the third faction, for convenience “JxC”, which is controlled by former Catalan President Carles Puigdemont, and has a strategy of escalating tension. The right nationalists are controlled by JxC (Puigdemont) in the Catalan parliament but PDCAT in Madrid. Puigdemont allegedly didn’t want to support the no-confidence motion, but the PDCAT realists prevailed in pushing for “yes” vote. This is very good news for lowering tension on this issue.

PSOE is essentially taking power as a result of machinations within parliament. Do they have any popular mandate?

I can’t say PSOE government is coming in with a strong mandate because it’s two years after the election, and they’ve come back into power via parliamentary maneuvers. There was strong support for getting rid of PP, and PSOE brought that motion. But it’s not clear what the positive mandate is for yet. That needs to be defined, and depends on the political skill of Sánchez, the party, and the government. The last term, the debt crisis caught the government largely by surprise, and it responded poorly and has been paying the price ever since.

What kind of lessons do you think PSOE has learned since then?

Sánchez in particular is defined by a couple of things, which are a kind of break from the PSOE that was in power during the crisis. One of them is that he was against what PSOE did in carrying out austerity measures and balancing budgets, which were wildly unpopular. When serving in party leadership, he came out against the party on that. He resigned his seat so as not to vote with the PP when PSOE was in a coalition with them.

He’s a guy who is here because he’s gone against the idea that what are needed are grand coalitions. That’s his claim to fame and why he’s been able to get as far as he has. In terms of specific questions around debt sustainability and eurozone reform, the party’s economic teams have been paying close attention to what’s been going on and are better equipped than last time around. The context now, of course, is very different because that was a full-blown crisis.

The PP enacted a number of regressive climate and energy policies, rolling back several pro-environment changes made by PSOE when they were in power. What are PSOE’s plans on climate?

News came out recently that the Spanish government had adapted one of the hardest lines against more ambitious climate targets. That’s kind of perplexing because Spain is on the frontlines of the climate crisis and should be on the frontlines of a green revolution. In terms of the climate, this could be a great opportunity. Sánchez’s team has strongly emphasized the climate issue, and the current president of the party is a former minister of the environment. The climate isn’t at the top of the Spanish agenda, but — in terms of the priorities that propelled Sánchez to regain PSOE leadership — it was more strongly emphasized than it was by Podemos.

How do you think this election will change the situation for Podemos-affiliated, left-leaning municipal parties like Barcelona En Comu, which have faced challenges from the national level as they’ve tried to implement a progressive agenda?

They’ve identified a series of bottlenecks, and it’s up to them to raise these issues and put them up on the agenda so that they can be solved — ideally by a change in regulation or a change in the existing laws. If they’ve engaged in all this learning about barriers at the national level, it’s in their own interest to propose these changes, so they can say they’ve achieved their agenda, and we can say we helped facilitate it. It’s in both of our interests.

Anything else?

We’ve had a right-wing government for the last seven years. The ruling party just faced an unprecedented corruption scandal and has been deeply anti-social when it comes to political rights. We haven’t sorted out the national question. It’s not an easy inheritance.

Correction: June 4, 2018, 3:00 p.m.

An earlier version of this story incorrectly referred to former Prime Minister Mariano Rajoy’s first name as Manuel. Also, the name of Spain’s center-right party, Ciudadanos, and David Lizoain’s last name were misspelled. The story has been updated.