Pedro Sanchez was sworn in as prime minister on Wednesday in a ceremony before King Felipe VI, becoming head of Spain's first-ever coalition government since the dictatorship ended in 1975.
He took the oath a day after being narrowly confirmed as premier in an investiture vote and will take over as head of a minority coalition government with the radical leftwing Podemos.
In a brief televised appearance at Zarzuela palace, Sanchez swore to uphold the constitution in a secular pledge with no Bible nor crucifix in sight -- as he did when first taking office in June 2018 which, back then, was a first.
The investiture draws a line under nearly a year of political deadlock in the eurozone's fourth-largest economy following inconclusive elections in April and again in November, both of which were won by the Socialists but without an absolute majority.
Sanchez will now focus on piecing together his government, with the lineup to be announced next week, party sources said.
He won Tuesday's confidence vote by an extremely tight margin in the bitterly-divided 350-seat chamber, with 167 votes in favour and 165 against -- and 18 crucial abstentions by Catalan and Basque separatist lawmakers.
November's election left the Socialists weakened, and even after the deal with Podemos, the two only accounted for 155 seats, 21 seats short of a majority, pushing Sanchez to seek support from smaller regional groups.
He also had to secure the all-important abstention of Catalan and Basque separatist parties, sparking a furious response from his rightwing rivals in the Popular Party, centre-right Ciudadanos and the far-right Vox.
Sanchez first took over as premier in June 2018 after an ambitious play saw him toppling PP premier Mariano Rajoy in a no-confidence vote.
But his new government will face an uphill battle to end the chronic instability that has plagued the eurozone's fourth-largest economy since 2015 when the decades-long hegemony of the Socialists and the PP fell apart.
With only 155 seats, it will struggle to push through legislation, with its first order of business to pass the long-overdue state budget -- a thorny issue which ended up bringing down Sanchez's first government and triggering last April's election.
The new coalition has pledged to raise the minimum wage and hike taxes on high earners and large businesses, while also repealing elements of the controversial 2012 labour market reforms, prompting industry warnings it could hurt job creation.