Spain’s Socialists have reached a preliminary agreement with the far-left Podemos party to form a coalition government following Sunday’s election, a senior Socialist source told Reuters on Tuesday.

The election — the country’s fourth in four years — left parliament even more fragmented 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 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 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 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 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 Iglesias would be deputy prime minister, something Sanchez had refused to agree to in the post-April election talks. Sanchez had also opposed a coalition government.

The two leaders said details of the preliminary agreement would come later and did not comment further.

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.