Spain's parliament has confirmed Socialist leader Pedro Sanchez's reappointment as prime minister by a razor-thin margin, ending almost a year of political limbo for the eurozone's fourth-largest economy.
Mr Sanchez, who plans to form an unprecedented minority coalition government with far-left party Podemos, got 167 votes in the 350-seat parliament, with 165 votes against and 18 abstentions.
It woud be the first coalition government in Spain since the country returned to democracy following the death of dictator Francisco Franco in 1975.
The two parties are pledging to lift the minimum wage, raise taxes on high earners and large businesses, and repeal elements of Spain's controversial 2012 labour market reforms that made it easier to fire workers - measures which business leaders warn will hurt job creation.
Mr Sanchez has also agreed to open a dialogue on the future of Catalonia, the conclusions of which would be put to a popular vote in the region.
He described dialogue with Catalonia, where separatism has been rife, as the "only possible path" forward, but made clear any negotiations must abide by the constitution, which upholds Spain's territorial integrity.
The Catalan independence push triggered Spain's most serious political crisis post-Franco.
Leader of the main opposition Popular Party, Pablo Casado, accused Mr Sanchez of forming a "Frankenstein government" made up of "communists" and "separatists" who "want to put an end to Spain."
He predicted that the minority government would not last the full four years.
But Mr Sanchez said there was "no other option" than a Socialist-Podemos government, adding that Spain could not go on without a proper administration.
"Without an elected government and parliament, it is obvious that our democracy suffers," he added.