MADRID: Spain’s center-right Prime Minister Mariano Rajoy was set to be voted out of office on Friday and replaced by a Socialist, in a no-confidence motion triggered by a long-running corruption trial involving members of his party.

Socialist leader Pedro Sanchez on Thursday secured the backing of six smaller parties for the motion, giving him the absolute majority he needs to take over from Rajoy as premier.

Rajoy’s departure after six years in office will cast one of the European Union’s top four economies into an uncertain political landscape, just as another  Italy appears to be emerging from a crisis of its own.

Anti-establishment parties in Rome revived coalition plans on Thursday, ending three months of turmoil by announcing a government that promises to increase spending, challenge European Union fiscal rules and crack down on immigration.

With most Spanish parties and Sanchez himself being pro-European, investors see less risk there than in Italy, where coalition leaders have also raised questions about the country’s commitment to the euro.

Rajoy’s position has become increasingly untenable, undermined by his status as head of a corruption-tinged minority government as well as a divisive independence drive in the wealthy region of Catalonia.

The Basque Nationalist Party, whose five seats were key to Sanchez securing enough parliamentary backing, withdrew support from Rajoy after dozens of people linked to his center-right People’s Party (PP) were sentenced to decades in jail in a corruption trial.

Two Catalan pro-independence parties as well as leftist Podemos also said they would back Sanchez. Market-friendly Ciudadanos, leading in the national opinion polls, was the only major party that said it would support Rajoy.

Sanchez said on Thursday he would stick to the budget put forward by Rajoy and approved by parliament last month if voted into power. He has promised to start talks with the Catalans but said he will not give them an independence referendum.

After the vote, Sanchez is expected to be sworn at the weekend and his cabinet appointed next week. However, with only 84 seats in the 350-seat parliament, his government will struggle to pass legislation.

A general election is due by mid-2020 and it is not clear whether Sanchez could call a snap vote before that. Many observers said he would likely wait until European, local and regional elections which will take place in May next year.

The parliamentary debate resumed at 9 am (0700 GMT) and the vote of confidence is expected at around 12 midday (1000 GMT).