MADRID (AP) — Spain’s Socialist Party has voted against party leader Pedro Sanchez in a move that seeks to end the party’s internal divisions on the country’s nine months of political deadlock.

After more than 10 hours of debate, Sanchez was defeated 132-107 in a vote Saturday and announced his resignation as party leader.

Sanchez had led the Socialists in blocking the conservative Popular Party’s Mariano Rajoy from building a minority government. His departure could end months of political gridlock in Spain, as the new Socialist party leadership may be more agreeable to letting Rajoy form a coalition government.

Spain has been led for decades by either the conservatives or the Socialists and has never had a coalition government.

THIS IS A BREAKING NEWS STORY. AP’S EARLIER STORY IS BELOW.

Spain’s Socialist Party is facing strong internal discord as they vote to decide if they will keep or oust their leader Pedro Sanchez, who has been leading a blockage to acting conservative Prime Minister Mariano Rajoy’s efforts to build a minority government and end a nine-month political deadlock.

Sanchez insists he will continue blocking Rajoy. If he preserves his leadership in the Saturday vote, Spain will be unable to form a government by Oct. 31 and a new round of elections will be called.

If his opponents win, renewed party leadership might abstain from blocking Rajoy, resulting in an end of the nine month deadlock.

Supporters of Pedro Sanchez have gathered outside Party headquarters chanting his name and “no means no,” in reference to the Socialists’ block of Rajoy’s Popular Party.

The Socialists’ internal dissent came on Wednesday after party icon and former Socialist Prime Minister Felipe Gonzalez revealed that Sanchez had told him they would abstain in the Rajoy vote. But the Socialists went on to block Rajoy.

In an attempt to force Sanchez to resign, 17 of the party’s 38-member executive committee resigned on Wednesday, demanding an end of the blockage.

The 137 year-old party is reeling in from its recent blow in the Galician and Basque regional Parliamentary elections and its worst-ever results in the two national elections, in December and June.

Some say, regardless of what the Socialists decide, the only winner will be Rajoy.

“The Spanish left is broken; there is no alternative to a Popular Party-led cabinet,” said Antonio Barroso of the Teneo Intelligence political risk consulting group in a note. “If Rajoy is not appointed PM before 31 October, new elections will only strengthen his party further and make his re-election more likely.”

Rajoy has been leading a caretaker government after the two elections. His party won the most seats in both but needs the support or abstention of other parties to form a government.

Ciaran Giles in Madrid contributed to this report.