MADRID (AP) — Prime Minister-elect Pedro Sanchez vowed Friday to root out the corruption that helped bring down Spain's outgoing conservative government and pledged to help people affected by years of public spending cuts under his predecessor, Mariano Rajoy.

Minutes after narrowly winning a no-confidence vote in parliament, the Socialist party leader signaled a change in tone and priorities from Rajoy's unbending commitment to reducing the national debt during his more than six years as prime minister.

Sanchez, the 46-year-old head of what has been Spain's main opposition party, has never held a government post.

He said he would address what he called the "social emergencies" of Spaniards after years of government austerity.

"I'm aware of the responsibility and the complex political moment of our country," Sanchez said in brief comments to reporters after the 180-169 vote in the Congress of Deputies, Spain's parliament. One lawmaker abstained.

Sanchez will be sworn in Saturday at 11 a.m. (0900 GMT, 5 a.m. EDT) by King Felipe VI at the Zarzuela Palace in Madrid and will appoint his Cabinet over the coming days. His triumph was a dramatic return to the spotlight after being fired as party leader less than two years ago.

Sanchez said he intended to call elections before the end of this parliamentary term in 2020, but he didn't say when, and he probably will want to make his mark first with some headline policies before going to the polls.

A tough path lies ahead for his minority government, however. It will face a political minefield as it tries to steer legislation through parliament by winning support from rival parties. The Socialists only have 84 seats — just under a quarter of the total.

Sanchez said he would seek to build a consensus to try to weed out corruption.

He also said he wanted to "transform and modernize" Spain, including improving job security, fighting inequality, providing a better life for the elderly and investing in public health care.

The former economics professor and career politician inherits a strong economy in which growth last year reached 3.1 percent. But a question remains over where he might find the money to pay for his Socialist party's ambitions.

Like the other 18 member countries of the eurozone shared currency bloc, Spain is locked into rules that keep a lid on spending and hold debt at sustainable levels. After the eurozone's recent financial crisis, any easing of those rules could spook markets.

Spain is the eurozone's fourth-largest economy and an influential member of the European Union. Sanchez and his party are staunch supporters of the EU and the shared currency.

Madrid's stock exchange didn't appear worried by Sanchez's rise to power, however, and it closed nearly 1.8 percent up from the previous day.

The downfall of Rajoy's government after nearly eight years in power came just days after his Popular Party's reputation was badly bruised by a court verdict that identified it as a beneficiary of a large kickbacks-for-contracts scheme. That ruling spelled the end of Rajoy's rule, and Sanchez was keen to portray himself as a fresh start.

Rajoy shook hands with Sanchez after the result was announced, leaving the chamber while lawmakers with the anti-establishment leftist party Podemos shouted "Yes, we can."

Sanchez has set himself apart from Rajoy's confrontational stance with separatists in Catalonia, Spain's wealthiest region, where the Catalan government is making a noisy new push for independence. Sanchez has promised to open talks with new Catalan President Quim Torra, despite having previously called the fervent secessionist's comments "xenophobic."

___

Associated Press writer Aritz Parra reported this story in Madrid and AP writer Barry Hatton reported from Lisbon, Portugal.

Copyright 2018 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.