Socialist Pedro Sanchez sworn in as Spain's prime minister

Pedro Sanchez was sworn in as Spain's prime minister Sunday, a day after the Socialist leader successfully ousted predecessor Mariano Rajoy who lost a no-confidence vote in parliament.

Rajoy was in attendance at the ceremony held in the royal Zarzuela Palace and shook Sanchez's hand after the new leader was sworn in by King Felipe VI before they posed for a photo with the monarch along with the speakers of the lower Congress of Deputies and the Senate.

Sanchez toppled Rajoy following a court ruling in a major corruption case involving the conservative leader's Popular Party. Parliament voted 180-169 Friday to replace Rajoy's government with one led by Sanchez. One lawmaker abstained.

Spain's socialist leader Pedro Sanchez, left, poses with King Felipe VI, center and former Prime Minister Mariano Rajoy after the swearing in ceremony at the Zarzuela Palace on the outskirts of Madrid, Spain, Saturday June 2, 2018. Pedro Sanchez has been sworn in as Spain's Prime Minister by King Felipe VI in a ceremony after coming to power Saturday a day after successfully leading a no-confidence vote to oust conservative Prime Minister Mariano Rajoy. (Emilio Naranjo/Pool Photo via AP)

Spain's socialist leader Pedro Sanchez, left, poses with King Felipe VI, center and former Prime Minister Mariano Rajoy after the swearing in ceremony at the Zarzuela Palace on the outskirts of Madrid, Spain.  (AP)

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

Sanchez has vowed to fight corruption and help those Spaniards affected by years of public spending cuts under Rajoy's government. He also pledged to hold an election soon, while not setting a date.

Sanchez will lead a minority government and will need the support of both the far-left Podemos (We Can) party and the backing of a motley crew of regional parties and Catalan secessionists to get anything done in government.

Sanchez has pledged to open talks with the separatist leader of northeastern Catalonia, which is set to recover the large degree of self-rule after chief Quim Torra swears in his Cabinet later on Saturday.

The forming of a Catalan government will automatically end the extraordinary takeover by Spain's central powers of the region as part of its crackdown following a failed declaration of independence by Catalonia in October.

The 46-year-old Sanchez is Spain's seventh prime minister since the return to democracy following the death of dictator Gen. Francisco Franco in 1975.