Spanish Prime Minister Mariano Rajoy was forced to step down Friday after losing a no-confidence motion in parliament.

Rajoy said it had been an “honor to serve” the Spanish people since 2011, but his position had become untenable following a corruption scandal that engulfed him and his People’s Party.

The 63-year-old will be replaced by Pedro Sánchez, leader of the Spanish Socialist Workers' Party, who proposed the no-confidence vote. “We're going to sign a new page in the history of democracy in our country," Sánchez said.

The new prime minister is expected to be sworn in at the weekend and will name a new cabinet next week.

The pivotal moment came Thursday when the Basque Nationalist Party (PNV) revealed it was going to back the no-confidence motion, joining the anti-austerity Podemos party, two Catalan pro-independence parties and another Basque party in supporting Sánchez’s motion.

Some 180 lawmakers ultimately backed the motion, with 169 voting against and one abstention.

The political upheaval in Spain comes amid a growing crisis in Europe. As well as the ongoing issues stalking Brexit negotiations, the rise of anti-establishment populism in Italy has caused disquiet among fellow members of the European Union — and a confrontation between Rome and Brussels looks inevitable, despite the swearing in of a new Italian government Thursday.

Why was Rajoy ousted?

The former prime minister was removed due to a scandal surrounding a secret campaign fund his party ran from 1999 until 2005, which it allegedly used for taking financial kickbacks in exchange for lucrative public contracts.

The controversy bubbled to the surface again last week when the former treasurer of the People’s Party, Luis Barcenas, was convicted of receiving bribes, money laundering and tax crimes by the High Court in Madrid.

He was one of 29 officials and businessmen convicted of securing bribes for municipal contracts, including businessman Francisco Correa, who was sentenced to 51 years in prison.

Rajoy was last year called as a witness in the trial, becoming the first Spanish prime minister to testify in court. Rajoy was at no point accused of wrongdoing.

Who is Sánchez?

Nicknamed “Mr. Handsome,” Sánchez is an economist and a former basketball player who shot to fame in 2014 when he unexpectedly won the party leadership.

But he’s had a bumpy political career since, suffering embarrassing election defeats in 2015 and again in 2016, after which he was forced to step down for refusing to let Rajoy form a government.

In a remarkable comeback, he returned to lead the Spanish Socialist Workers' Party a year ago, and has since been urging Rajoy to resign to avoid the ignominy of a no-confidence vote.

What does this mean for Spain?

Because of the way Rajoy was removed, Sánchez must now try to form a government — but it is unclear what type of coalition he’ll be able to cobble together.

With just 84 seats in parliament, Sánchez’s PSOE party holds less than a quarter of all seats. While he can rely on the support of Podemos, he is unlikely to sway the centrist Ciudadanos party, which supported Rajoy.

There is likely to be limited upheaval in how the government operates initially, but Sánchez has promised to open talks with the Catalan separatists, indicating he is willing to take a more constructive approach to the constitutional crisis sparked by the referendum in the semi-autonomous region.

In theory Sanchez could stay in power until mid-2020, but he has indicated he will call early elections — though hasn’t said when.

What does this mean for the EU?

Markets across Europe have been rattled by recent political turmoil in Spain and Italy.

Although there was no great market reaction to Rajoy’s ouster Friday, uncertainties about Sánchez’s ability to lead will likely be a cause for concern for investors and regulators across the bloc.

Sánchez has said he will stick to the budget Rajoy recently negotiated — which should allay some fears within the EU. But with Italy’s fledgling government on a knife edge, and a political outsider now running Spain, Brussels will likely be watching its southern members very closely in the coming months.