Spain's Socialists and far-left Unidas Podemos party agreed on the basis of a coalition government on Tuesday, just two days after a parliamentary election delivered a highly fragmented parliament.
The election - the country's fourth in four years - left Spain's parliament even more divided than a previous ballot in April, with the Spanish Socialist Workers' Party (PSOE) retaining its lead but further away from a majority.
It's a deal for four years, Socialist leader Pedro Sanchez, who is currently acting prime minister, said after signing the pact alongside Podemos leader Pablo Iglesias.
The unexpectedly fast preliminary agreement would require further steps including bringing in smaller parties and agreeing on who gets what position in the cabinet.
If confirmed, it would be Spain's first coalition government since the country's return to democracy in the late 1970s. Spain needs a stable government, a solid government, Sanchez said, adding that the deal was open to others.
The combination of the 120 seats obtained by the Socialists and the 35 of Unidas Podemos falls short of a majority in the 350-seat parliament.
The Socialists and Podemos had tried and failed to strike a government deal after the April election, which had prompted Sanchez to call the repeat ballot. The two men had been at odds for months and exchanged harsh words as acrimonious talks failed after the April election. On Tuesday they were all smiles, hugging after they signed the pact.
We've reached a preliminary agreement to create a progressive coalition government in Spain, which combines the experience of PSOE with the courage of Unidas Podemos, Iglesias said.
Local media including La Sexta TV said that Iglesias would be deputy prime minister, something which Sanchez had refused in the post-April election talks. Sanchez had also at the time opposed a coalition government.
El Diario newspaper said they would try to get other parties on board, including the market-friendly Ciudadanos, far-left Mas Pais and the Basque nationalist PNV.