Prime Minister Pedro Sanchez, of Spain's Socialist PSOE party, and Unidas Podemos leader Pablo Iglesias struck a deal on Tuesday to form a minority coalition.

Sanchez said he was confident of forming a Cabinet that would act with loyalty and internal solidarity. "The agreement is for four years," he said.

Read more: Opinion — Spain needs a new political culture

Coalition talks that took place after Sunday's election — the country's fourth in four years — left Spain with a parliament even more fragmented than after a previous ballot in April.

The agreement raises the prospect of an end to Spain's political deadlock, with the two party leaders having had long and unsuccessful negotiations after the April election.

"An agreement has been reached for a coalition government between Unidas Podemos and the Socialists," Podemos lawmaker Alberto Garzon said in a tweet. "Today is a day for celebration. We have shown that it can be done."

Iglesias said that the coalition would bring together PSOE's experience and the courage of Podemos.

However, even with a deal, the two parties still need to find more allies. Combined, the 120 seats won by the Socialists and the 35 for Podemos fall 21 short of the 176 needed for a majority in Spain's 350-seat parliament.

Possible parties to make up the shortfall could be the leftist Mas Pais and the Basque nationalist PNV, speculated El Diario newspaper.

Read more: Catalan protesters — 'We want to make a point'

PSOE emerged as the largest party this time around, but it lost seats compared with the previous election, while Podemos saw even more seats fall away. The far-right Vox gained 52 seats, becoming the third-largest party after PSOE and the center-right People's Party (PP), which notched up 87 seats.

kmm,rc/msh (Reuters, dpa, EFE)

Each evening at 1830 UTC, DW's editors send out a selection of the day's hard news and quality feature journalism. You can sign up to receive it directly here.