MADRID — The leader of Spain’s main opposition Socialist Party resigned on Saturday night after losing a bruising and chaotic battle against other senior party members who were opposed to prolonging the deadlock in Spanish politics.  The Socialists’ leader, Pedro Sánchez, stepped down after a majority of his party’s federal committee voted against his proposal to hold new party primaries on Oct. 23. The proposal would almost certainly have forced Spain to hold a third national election because of an Oct. 31 deadline to form a new government.  Spain has been without an elected government since an inconclusive national election in December. Mr. Sánchez had refused to allow Mariano Rajoy, the caretaker prime minister, to start a new term, arguing that Mr. Rajoy was unfit for office largely because of corruption scandals that have tainted his conservative Popular Party. Mr. Rajoy, however, has insisted that he should stay in charge after his party twice won national elections — in December and June — but both times without a parliamentary majority.  Mr. Sánchez lost on Saturday by a vote of 133 to 109. The Socialist leadership will be taken over by a caretaker management committee whose first task is likely to be to confirm whether the Socialists will change tack and no longer block Mr. Rajoy’s re-election.  The committee must also begin the difficult job of reuniting a Socialist Party battered by election defeats and fractured by the tussle to remove Mr. Sánchez. Susana Díaz, the Socialist leader of the southern region of Andalusia, pushed to oust Mr. Sánchez and is seen as the front-runner to eventually succeed him.  Mr. Sánchez tried unsuccessfully this year to form a government of his own, in coalition with Ciudadanos, a smaller centrist party that has since switched its support to Mr. Rajoy.  “I always thought the Socialist Party should provide an alternative,” Mr. Sánchez said at a news conference on Saturday. “Unfortunately it didn’t prove possible during the last legislature.”  A version of this list appears in print on October 2, 2016, on page A8 of the New York edition with the headline: Top Socialist in Spain Is Out Amid Impasse. Order Reprints| Today's Paper|Subscribe
Senior party members forced Pedro Sánchez to resign as they sought to end internal divisions and break the impasse that has left Spain without an elected government.