Spain
Spain's Prime Minister Mariano Rajoy is applauded by members of his party during the second day of a motion of no confidence session at the Spanish parliament in Madrid, Friday, June 1, 2018. Socialist opposition leader Pedro Sanchez is on the brink of ending Mariano Rajoy's more than six-year reign as Spanish prime minister in what would be the first ouster of a serving leader by parliament in four decades of democracy as Spain's conservative government appears doomed to lose a no-confidence vote in parliament(AP Photo/Francisco Seco)
PHOTO: Francisco Seco/AP
Now playing
01:44
Rajoy forced out as Spain's Prime Minister
Spanish Prime Minister Mariano Rajoy speaks during the national convention of ruling
Spanish Prime Minister Mariano Rajoy speaks during the national convention of ruling 'Popular Party' PP (People's Party) in Sevilla on April 8, 2018. / AFP PHOTO / CRISTINA QUICLER (Photo credit should read CRISTINA QUICLER/AFP/Getty Images)
PHOTO: CRISTINA QUICLER/AFP/AFP/Getty Images
Now playing
01:04
Spanish PM concedes likely defeat in no-confidence vote
Spanish Prime Minister Mariano Rajoy speaks during a press conference at La Moncloa palace in Madrid on October 1, 2017.
Spanish Prime Minister Mariano Rajoy speaks during a press conference at La Moncloa palace in Madrid on October 1, 2017.
PHOTO: JAVIER SORIANO/AFP/Getty Images
Now playing
02:34
Spanish PM: Catalonia referendum is illegal
BRUSSELS, BELGIUM - OCTOBER 20:  Spain
BRUSSELS, BELGIUM - OCTOBER 20: Spain's Prime Minister Mariano Rajoy answers questions during a press conference on the second day of European Council meetings at the Council of the European Union building on October 20, 2017 in Brussels, Belgium. Britain's Prime Minister Theresa May attended meetings yesterday with the other 27 EU leaders, which concluded with a dinner speech, in which she asked that she could strike a Brexit deal that she can defend to UK voters. (Photo by Dan Kitwood/Getty Images)
PHOTO: Dan Kitwood/Getty Images
Now playing
02:31
Rajoy urges removal of Catalan President
spain prime minister punched ct_00002602.jpg
spain prime minister punched ct_00002602.jpg
PHOTO: Reuters/Diario de Pontevedra
Now playing
00:51
Spanish PM gets punched at campaign event
Protesters clash with riot police blocking the road leading to the central government offices during a demonstration in Barcelona on March 25, 2018 after Catalonia
Protesters clash with riot police blocking the road leading to the central government offices during a demonstration in Barcelona on March 25, 2018 after Catalonia's former president was arrested by German police. German police arrested Catalonia's deposed leader Carles Puigdemont on March 25, 2018, five months after he went into self-imposed exile in Belgium over his failed bid to break the region away from Spain. / AFP PHOTO / LLUIS GENE (Photo credit should read LLUIS GENE/AFP/Getty Images)
PHOTO: LLUIS GENE/AFP/Getty Images
Now playing
01:30
Thousands protest after Catalonian ex-leader detained
Spain
Spain's Propaganda War_00001317.jpg
Now playing
03:08
Spain's propaganda war
A man wearing an Catalan barretina hat kisses his ballot before casting his vote for the Catalan regional election at a polling station in Barcelona on December 21, 2017.
Catalans take their divisions over independence to the polls today in a hotly-contested election that could determine the course of their region just two months after a failed secession bid.

 / AFP PHOTO / LLUIS GENE        (Photo credit should read LLUIS GENE/AFP/Getty Images)
A man wearing an Catalan barretina hat kisses his ballot before casting his vote for the Catalan regional election at a polling station in Barcelona on December 21, 2017. Catalans take their divisions over independence to the polls today in a hotly-contested election that could determine the course of their region just two months after a failed secession bid. / AFP PHOTO / LLUIS GENE (Photo credit should read LLUIS GENE/AFP/Getty Images)
PHOTO: LLUIS GENE/AFP/Getty Images
Now playing
01:44
Catalans back pro-independence parties
People wave
People wave 'Esteladas' (pro-independence Catalan flags) as they gather during a pro-independence demonstration, on September 11, 2017 in Barcelona during the National Day of Catalonia, the "Diada." Hundreds of thousands of Catalans were expected to rally to demand their region break away from Spain, in a show of strength three weeks ahead of a secession referendum banned by Madrid. The protest coincides with Catalonia's national day, the "Diada," which commemorates the fall of Barcelona in the War of the Spanish Succession in 1714 and the region's subsequent loss of institutions and freedoms. / AFP PHOTO / PAU BARRENA (Photo credit should read PAU BARRENA/AFP/Getty Images)
PHOTO: PAU BARRENA/AFP/AFP/Getty Images
Now playing
02:24
How Catalonia's independence crisis unfolded
(CNN) —  

Spanish Prime Minister Mariano Rajoy was toppled by a corruption scandal Friday, becoming the first leader in Spain’s modern democracy to lose a vote of no confidence in Parliament.

The demise of Rajoy – one of Europe’s longest-serving political leaders – paves the way for Pedro Sánchez, the leader of the main opposition Socialist party, to become Prime Minister.

Friday’s vote in Madrid was the culmination of years of corruption allegations against Rajoy’s Popular Party (PP). The scandal came to a head last week when a court convicted his former aides of running slush funds to help finance PP election campaigns, prompting Sánchez to file the confidence motion.

The fall of Rajoy’s government comes at a time of wider political turmoil in Europe. Two populist parties in Italy have just reached an agreement to form a coalition government after months of wrangling, Brexit dominates UK politics and the European Union must now contend with a looming trade war with the US.

Spain’s political tumult is born of a long-running corruption scandal coupled with internal division. Although still feeling the effects of the global economic crisis, Spain’s economy is performing better than that of Italy, and anti-European sentiment played no part in its change of government.

Pedro Sanchez poses in the parliament after the motion of no confidence vote Friday.
Pedro Sanchez poses in the parliament after the motion of no confidence vote Friday.
PHOTO: Francisco Seco/AP

Nonetheless, Sánchez, leader of the Spanish Socialist Workers’ Party (PSOE), faces significant challenges as he assumes office. Spain was riven last year by the Catalan independence crisis, which remains unresolved.

Rajoy’s fate was sealed on Thursday after the Socialists secured support for the no-confidence motion from a number of smaller parties in Parliament, including the Basque Nationalist Party.

In total, 180 of the chamber’s 350 lawmakers voted in support of the motion, a clear majority. There were 169 votes against and one abstention. It was the first time in Spain’s post-1977 democracy that a Spanish Prime Minister has fallen in this way.

Ana Pastor, President of the lower house of the Spanish Parliament, announced that Sánchez has “the trust of the Parliament” and so becomes the new Prime Minister of Spain. In line with the constitution, she was to inform Spain’s King Felipe II on Friday afternoon.

Sánchez received a standing ovation, with parliamentarians shouting: “Yes, it can be done.”

Outgoing Prime Minister Mariano Rajoy, left, shakes hands with Spain
Outgoing Prime Minister Mariano Rajoy, left, shakes hands with Spain's new Prime Minister Pedro Sanchez after the vote.
PHOTO: EMILIO NARANJO/AFP/Getty Images

Rajoy shook hands with Sánchez, his 46-year-old successor, to congratulate him. Speaking shortly before the vote, Rajoy said he had been proud to serve his country. “It has been an honor to leave a better Spain than I found,” he said. “I wish my substitute could say the same when his day comes, for the good of Spain.”

Sánchez – a pro-European economics professor who was a keen basketball player in his youth – previously said that he would call for snap elections should he become Prime Minister.

He is expected to take office and nominate his Cabinet next week.

Posting on Twitter, Sánchez promised a fresh start for the country. “Spain starts a new page. A period to recover the dignity of its institutions. From responsibility, dialogue and consensus, it is time to work for equality, to build a country that does not leave anyone behind,” he said.

Separatist parties

Sánchez became PSOE leader in 2014, when the photogenic then-42-year-old was thought of as the new young and “handsome” face of politics.

But in 2016 his party performed poorly in elections and was unable to assemble a coalition government to keep Rajoy out of power. That didn’t sit well with some people in his party and in October of that year he resigned under pressure.

Pedro Sánchez addresses lawmakers Friday on the second day of debate on the no-confidence motion.
Pedro Sánchez addresses lawmakers Friday on the second day of debate on the no-confidence motion.
PHOTO: JJ GUILLEN/EPA-EFE

He then presented himself as a candidate for the primaries and won comfortably in 2017, proof that he remained popular with socialists in Spain. However, critics have accused him of wanting to become Prime Minister whatever the price.

Sánchez needed the support of fringe and pro-independence parties, as well as the anti-austerity Podemos party, to push the confidence motion through Parliament. And, since his own party holds only 84 seats, Sánchez will need to keep those parties, with their differing agendas, on his side in order to pass any legislation.

He has previously said he would stick to the budget recently passed by Rajoy’s government and continue to enact socioeconomic reforms.

Nathan Jones, a Spanish politics expert at Britain’s Nottingham Trent University, said the ousting of Rajoy’s government represented another step into the unknown for Spain.

“Thus far, few of the parties who backed the vote of no confidence in Rajoy have indicated that they will support Sánchez’s government, increasing the probability of a snap general election, the third since 2015, having to be called,” he said.

“Support for Sánchez from parties other than Podemos may yet still emerge; however, significant divisions remain between many of the political parties, thus establishing a stable government is far from certain.”

Rajoy: ‘A better Spain’

Rajoy, who came to office in 2011, had effectively conceded defeat ahead of the vote, congratulating Sánchez on his expected win in a brief address to Parliament.

“In light of what we all know, I presume that the vote of no confidence will go ahead, and Pedro Sánchez will become the Prime Minister and I want to be the first to congratulate him,” Rajoy said, visibly moved as he gave what was to be his last address as Spain’s leader.

“I will accept the result of the vote as the democrat I am, but I cannot agree with what has been done.”

Mariano Rajoy pauses during a speech ahead of the confidence vote on Friday at the Spanish parliament in Madrid.
Mariano Rajoy pauses during a speech ahead of the confidence vote on Friday at the Spanish parliament in Madrid.
PHOTO: Francisco Seco/AP

Rajoy’s party has been plagued with corruption allegations for years. Rajoy himself has faced the humiliation of testifying in cases against PP members, though he has not been among the accused.

The confidence motion was filed by Sánchez after a court convicted Rajoy’s former aides of running slush funds to help finance Popular Party election campaigns. The court also questioned the credibility of Rajoy’s testimony during the proceedings.

It was the first time in Spain that a party had been convicted and fined on corruption-related charges.

Jean-Claude Juncker, president of the European Commission, tweeted his congratulations to Sánchez. “I trust that the Spanish government will continue contributing in a constructive way for a Europe that is stronger, more united and fairer,” he said, adding that Spain “plays a very important role” in the European project.

European Council President Donald Tusk also offered his congratulations, saying Sánchez’s appointment came at a “challenging time” for the continent. “European unity is now more needed than ever,” he said in a statement.

The Party of European Socialists (PES), made up of parties from across the European Union, welcomed Sánchez’s election, saying his government would form a “credible alternative to a conservative government hounded by corruption.”

PES President Sergei Stanishev described Sánchez as “a progressive and honest pro-European” who would “shift away from the austerity policies of the past years in his country.”

CNN’s Laura Perez Maestro reported from Madrid and Laura Smith-Spark wrote from London. CNN’s Vasco Cotovio contributed to this report.