Spanish Prime Minister Pedro Sanchez attends a debate on the government's 2019 budget during a parliament session in Madrid on February 13, 2019.

Spain's Socialist leader Pedro Sanchez failed on Sunday in a first attempt to get parliament's backing to form a government, leaving him two days to secure support to end an eight-month political gridlock.

Sanchez has been acting prime minister since a first inconclusive election in April and November did not produce a conclusive result. He needed an absolute majority of at least 176 votes in his favour in the 350-seat house to be confirmed as prime minister but failed to get it.

He obtained 166 votes in favur and 165 against, with 18 abstentions, while one lawmaker did not attend.

On Tuesday, Sanchez will only need a simple majority - more "yes" than "no" votes. He is likely to get that after securing a commitment from the 13 lawmakers of Catalonia's largest separatist party, Esquerra Republicana de Catalunya (ERC), to abstain.

Earlier this week, Socialist Party leader Sanchez and Pablo Iglesias, head of the far-left party Unidas Podemos, restated their intention to form the first coalition government in Spain's recent history.

The two parties together have 155 seats, short of a majority, so Sanchez is reliant on the votes of small regional parties.

In a sign of how close the race could be on Tuesday, a member from the small regional party Coalicion Canaria, Ana Oramas, voted against Sanchez instead of abstaining as her party had agreed on Friday.

During Sunday morning's debate, Sanchez stressed that a Socialist-Podemos coalition would take a progressive approach. Sanchez and Iglesias have said they will push for tax hikes on high-income earners and companies and also intend to roll back a labour reform passed by a previous conservative government.

The morning was marked by tension during the speech of Mertxe Aizpurua of pro-independence Basque party EH Bildu. Aizpurua called the conservative and right wing parties People's Party, Vox and Ciudadanos "Francoists", a reference to late dictator Francisco Franco, and criticised the Constitution and King Felipe.

She was met with boos and shouts of "murderers".