By Angus Berwick and Carlos Ruano
MADRID (Reuters) - The leader of Spain's Socialists resigned on Saturday after losing a vote triggered by a party revolt, a step which could pave the way for the formation of a new government and end a nine-month political deadlock.
Pedro Sanchez had been in a stand-off with acting Prime Minister Mariano Rajoy's People's Party (PP), frustrating attempts to form a government after two elections left the conservatives with the most votes but shy of a majority.
Members of the bitterly divided Socialist assembly met on Saturday to decide whether to open up a leadership race in October, as proposed by Sanchez, or oust him.
Shouts from the meeting at the party headquarters in the capital Madrid were heard from outside as members argued over what the vote should be. One person stormed out before the end saying the party was "broken" and Sanchez eventually lost by 132 votes to 107 after a tumultuous 10-hour debate.
"Today, following a day of intense debates, a vote was held on whether a party conference should take place on Oct. 23 so that the grassroots could pick their leader ... Unfortunately, I have lost this vote and I have resigned as secretary general of the party," Sanchez told a news conference.
The departure of Sanchez, who became leader in 2014 and has presided over a slump in party support, means the Socialists can now try to find ways to avoid a third election, such as abstaining in a confidence vote to allow Rajoy a second term.
The Socialists will be under interim management until a party conference can choose a new leader. Party insiders say the powerful head of the Andalusia region, Susana Diaz, is the favorite though it is not clear when a new secretary general will be picked.
The interim management will face one of the party's biggest dilemma's since it was founded in 1879: allow a conservative minority government or force a third general election in a year.
Most observers and analysts believe the Socialists will go for the first option, to give them time to regroup and not run the risk of losing more ground in a third election in a year.
"Overall, I believe it is now more likely that Spain will not need a third general election. The mutiny against Pedro Sanchez was at least in part due to his intransigence in refusing to let Rajoy form a minority government despite it being clear that the Socialist leader could offer no credible alternative," said Vincenzo Scarpetta, a political analyst at the Open Europe think tank in London.
"Furthermore, the Socialist Party clearly doesn't look in an ideal state to fight an election campaign. The impression is it might need quite some time to regroup," he said.
If no government is formed before the end of October, a third election will be called in December.
Although Spain's economic recovery has weathered the political impasse so far, there are signs that further uncertainty could slow growth and hamper investment.
For months, Sanchez has refused to change his opposition to enabling a minority government led by Rajoy, who he chastizes as corrupt. In August, Rajoy lost a confidence vote in parliament after the Socialists voted "No".
The Socialists governed Spain from 2004 to 2011 but the new political forces that have emerged since the country's financial crisis have eaten into their support base and Sanchez notched their worst ever national election result in June.
(Additional reporting by Blanca Rodriguez; editing by Julien Toyer and David Clarke)