For most Israelis, the general election on Tuesday was about one thing and one thing only. Not the economy, nor the occupation, nor even corruption scandals. It was about Benjamin Netanyahu. Should he head yet another far-right government, or should his 10-year divisive rule come to an end?

Barring a last-minute upset as the final ballot papers are counted, Israelis have made their verdict clear: Netanyahu’s time is up.

In April’s inconclusive election, which led to this rerun, Netanyahu’s Likud party tied with its main opponent in the Blue and White party, led by retired general Benny Gantz. This time Gantz appears to have nudged ahead, with 32 seats to Netanyahu’s 31 in the 120-member parliament. Both parties fared worse than they did in April, when they each secured 35 seats.

But much more significantly, Netanyahu appears to have fallen short of the 61-seat majority he needs to form yet another far-right government comprising settler and religious parties.

His failure is all the more glaring, given that he conducted by far the ugliest – and most reckless – campaign in Israeli history. That was because the stakes were sky-high.

Only a government of the far-right – one entirely beholden to Netanyahu – could be relied on to pass legislation guaranteeing him immunity from a legal process due to begin next month. Without it, he is likely to be indicted on multiple charges of fraud and breach of trust.

So desperate was Netanyahu to avoid that fate, according to reports published in the Israeli media on election day, that he was only a hair’s breadth away from launching a war on Gaza last week as a way to postpone the election.

Israel’s chief law officer, attorney general Avichai Mendelblit, stepped in to halt the attack when he discovered the security cabinet had approved it only after Netanyahu concealed the army command’s major reservations.

Netanyahu also tried to bribe right-wing voters by promising last week that he would annex much of the West Bank immediately after the election – a stunt that blatantly violated campaigning laws, according to Mendelblit.

Facebook was forced to shut down Netanyahu’s page on two occasions for hate speech – in one case after it sent out a message that “Arabs want to annihilate us all – women, children and men”. That sentiment appeared to include the 20 per cent of the Israeli population who are Palestinian citizens.

Netanyahu incited against the country’s Palestinian minority in other ways, not least by constantly suggesting that their votes constituted fraud and that they were trying to “steal the election”.

He even tried to force through a law allowing his Likud party activists to film in Arab polling stations – as they covertly did in April’s election – in an unconcealed attempt at voter intimidation.

The move appeared to have backfired, with Palestinian citizens turning out in larger numbers than they did in April.

US President Donald Trump, meanwhile, intervened on Netanyahu’s behalf by announcing the possibility of a defense pact requiring the US to come to Israel’s aid in the event of a regional confrontation.

None of it helped.

Netanayhu’s only hope of political survival – and possible avoidance of jail time – depends on his working the political magic he is famed for.

That may prove a tall order. To pass the 61-seat threshold, he must persuade Avigdor Lieberman and his ultra-nationalist Yisrael Beiteinu party to support him.

Netanyahu and Lieberman, who is a settler, are normally ideological allies. But these are not normal times. Netanyahu had to restage the election this week after Lieberman, sensing the prime minister’s weakness, refused in April to sit alongside religious parties in a Netanyahu-led government.

Netanyahu might try to lure the fickle Lieberman back with an irresistible offer, such as the two of them rotating the prime ministership.

But Lieberman risks huge public opprobrium if, after putting the country through a deeply unpopular rerun election, he now does what he refused on principle to do five months ago.

Lieberman has nearly doubled his party’s seats to nine, by insisting that he is the champion of the secular Israeli public.

Most importantly for Lieberman, he finds himself once again in the role of kingmaker. It is almost certain he will shape the character of the next government. And whoever he anoints as prime minister will be indebted to him.

The deadlock that blocked the formation of a government in April still stands. Israel faces the likelihood of weeks of frantic horse-trading and even the possibility of a third election.

Nonetheless, from the perspective of Palestinians – whether those under occupation or those living in Israel as third-class citizens – the next Israeli government is going to be a hardline right one.

On paper, Gantz is best placed to form a government of what is preposterously labeled the “center-left”. But given that its backbone will comprise Blue and White, led by a bevy of hawkish generals, and Lieberman’s Yisrael Beiteinu, it would, in practice, be nearly as right wing as Netanyahu’s.

Gantz even accused Netanyahu of stealing his idea in announcing last week that he would annex large parts of the West Bank.

The difficulty is that such a coalition would depend on the support of the 13 Joint List legislators representing Israel’s large Palestinian minority. That is something Lieberman has rejected out of hand, calling the idea “absurd” early on Wednesday as results were filtering in. Gantz appears only a little more accommodating.

The solution could be a national unity government comprising much of the right: Gantz’s Blue and White teamed up with Likud and Lieberman. Both Gantz and Lieberman indicated that was their preferred choice on Wednesday.

The question then would be whether Netanyahu can worm his way into such a government, or whether Gantz demands his ousting as a price for Likud’s inclusion.

Netanyahu’s hand in such circumstances would not be strong, especially if he is immersed in a protracted legal battle on corruption charges. There are already rumblings of an uprising in Likud to depose him.

One interesting outcome of a unity government is that it could provoke a constitutional crisis by making the Joint List, the third-largest party, the official opposition. That is the same Joint List described by Netanyahu as a “dangerous anti-Zionist” party.

Ayman Odeh would become the first leader of the Palestinian minority to attend regular briefings by the prime minister and security chiefs.

Netanyahu will continue as caretaker prime minister for several more weeks – until a new government is formed. If he stays true to form, there is plenty of mischief he can instigate in the meantime.

Jonathan Cook won the Martha Gellhorn Special Prize for Journalism. His latest books are Israel and the Clash of Civilizations: Iraq, Iran and the Plan to Remake the Middle East (Pluto Press) and Disappearing Palestine: Israel’s Experiments in Human Despair (Zed Books). His website is www.jonathan-cook.net. This originally appeared on The National.