Israeli Arab political parties have broken with longstanding precedent and endorsed the ex-military chief Benny Gantz for prime minister, in a bid to prevent the incumbent, Benjamin Netanyahu, from forming the next government.

The dramatic move came after the mainly Arab Joint List alliance won 13 seats in Tuesday’s polls, making the bloc the third-largest force in the 120-seat parliament.

In announcing the decision, Joint List leader Ayman Odeh said the alliance’s decision was not an endorsement of Gantz’s policies but a move to oust Netanyahu, Israel’s longest-serving prime minister.

It was the first time that majority Arab parties had endorsed a candidate for prime minister since 1992, when they backed Yitzhak Rabin, who went on to sign the Oslo accords with the Palestinians.

Netanyahu has repeatedly been accused of political rhetoric and actions amounting to racism toward Israel’s Arab population. “We have become illegitimate in Israeli politics in the Netanyahu era,” Odeh told Israeli president Reuven Rivlin when informing him of the endorsement. “We are this time recommending Benny Gantz to form the next government.”

Prominent Arab parliament member Ahmad Tibi said “history is done: We’ll do what is needed to bring down Netanyahu.”

But the success of the Arab parties’ mission to end Netanyahu’s long dominance of Israeli politics was far from certain.

Rivlin, who began holding consultations with parties on Sunday to hear their recommendations on who should form the next government, said he believed both Netanyahu’s rightwing Likud and Gantz’s centrist Blue and White should be in the next coalition.

Quick Guide The police investigations swirling around Netanyahu Show The Israeli PM is embroiled in four cases involving allegations of bribery and misconduct. He denies wrongdoing in every instance. Case 1000 is an investigation into gifts received on a regular basis by Netanyahu and his family from two wealthy businessmen, including cigars and pink champagne. Case 2000 is examining whether Netanyahu behaved improperly during a taped conversation with a newspaper publisher in which he appeared to try to negotiate more sympathetic coverage in return for lowering the circulation of a rival paper. Case 3000 is an inquiry into alleged kickbacks in a deal to buy German submarines. Netanyahu is not a suspect, but he was closely involved in the deal and the case has ensnared members of his inner circle.

Case 4000, the most serious, involves allegations that Netanyahu offered incentives to the Israeli telecoms company Bezeq in exchange for positive stories in an online news website it owns, Walla.

He must designate someone to form a government after the consultations, though there has been speculation that he will bring Gantz and Netanyahu together to explore options for a unity government.

Tuesday’s elections ended in yet another deadlock, the second after April polls also finished inconclusively.

Blue and White won the most seats, with 33 out of parliament’s 120, while Likud finished second with 31. Neither has an obvious path to a majority coalition.

Gantz is expected to have the endorsement of 57 seats during Rivlin’s consultations, which continue on Monday. Netanyahu is expected to receive 55.

Those totals do not include ex-defence minister Avigdor Lieberman’s nationalist Yisrael Beitenu party, which won eight seats.

Lieberman, who could potentially play a king-maker role, said on Sunday that he would not endorse either Netanyahu or Gantz for now. He has insisted on a unity government between his party, Netanyahu’s rightwing Likud and Gantz’s centrist Blue and White.

He added that for the time being he could not back Netanyahu because the premier is willing to form a coalition with Israel’s ultra-Orthodox Jewish parties, which he accuses of seeking to impose religious law on the secular population.

Lieberman also said he could not back Gantz for now because he might reach a deal with either the ultra-Orthodox or Israel’s Arab parties, which he called “enemies”.

Faced with disappointing results last week, Netanyahu acknowledged he was unable to form the rightwing coalition he had hoped for and called on Gantz to join him in a unity government.

But Gantz, who has also called for a unity government, made his position clear: He must be prime minister under any such arrangement, since his party has the most seats.

Rivlin would “make every effort to prevent a third set of elections,” Harel Tubi, director general of the president’s office, told Israel’s army radio on Sunday.

The end of the Netanyahu era would be an extraordinary moment in Israeli politics, as he has been prime minister for a record-breaking total of more than 13 years.

The 69-year-old faces potential corruption charges in the weeks ahead, pending a hearing set for early October.

Gantz has in the past spoken of his refusal to serve in a government with an indicted prime minister. Nevertheless, he has not repeated that statement in recent days, beyond saying he should be the premier himself.