Pedro Sanchez, head of Spain's Socialist Party (PSOE), resigned late Saturday in an intra-party squabble over whether to support a conservative-led governing coalition.
He had quit after losing the support of a majority of the party's central committee, Sanchez told reporters.
He had opposed allowing acting Prime Minister Mariano Rajoy of the conservative People's Party (PP) to form a government. Sanchez's departure could pave the way for a new government, which Spain has sought for almost nine months.
In September, Parliament rejected Rajoy's latest attempt to win a confidence vote to form a new government, edging Spain closer to its third election in a year.
Rajoy was buoyed a week ago by his party's success in provincial elections in his home region of Galicia, where the People's Party have held power for the last four years.
Sanchez's opposition to a Rajoy-led government had bitterly split the Socialist Party.