Nikola Gruevski faces charges of corruption and abuse of power in several legal cases following a major wiretapping scandal.
Macedonia's ex-prime minister Nikola Gruevski, whose powerful decade-long reign ended last year because of a corruption scandal, has quit his position as head of the conservative VMRO-DPMNE party.
The 47-year-old leader presented his "irrevocable resignation" on Sunday evening, VMRO-DPMNE said in a statement on Monday.
"Gruevski said that ... his resignation was a moral act, as it is natural that the person in whom everyone had confidence should take the responsibility for the (electoral) defeat," the statement said.
Gruevski's resignation comes two weeks ahead of a party congress.
He and several other conservative party members are under investigation over 2015 wiretapping allegations.
The scandal surfaced after Zoran Zaev, the leader of social democrats and the main opposition party SDSM, released tapes that appeared to confirm official wiretapping of 20,000 Macedonian citizens, including politicians and journalists, and high-level corruption.
The revelations led to Gruevski's resignation from government in January 2016 and plunged the country into a deep crisis.
The turmoil only eased when Zaev became prime minister in spring this year after striking a controversial deal with minority ethnic Albanian parties following snap elections in December.
Gruevski's successor is due to be elected at an extraordinary party congress on December 22 and 23.