Israel was approaching the end of an era after the last-minute formation of a motley coalition that could in the next few days oust veteran leader Benjamin Netanyahu, the country's longest-serving prime minister.

Opposition leader Yair Lapid announced the deal just minutes before a midnight Wednesday deadline, prompting celebrations into the early hours by the premier's opponents and a defiant show of support by his fans.

Israel's centrist opposition leader Yair Lapid announced the deal to unseat veteran Prime Minister Benjamin Netanyahu less than an hour before a midnight deadline
Israel's centrist opposition leader Yair Lapid announced the deal to unseat veteran Prime Minister Benjamin Netanyahu less than an hour before a midnight deadline POOL / DEBBIE HILL

On paper, the prospective coalition commands a slender majority in parliament but a confidence vote is not expected for several days, giving Netanyahu time to woo potential defectors among the unlikely bedfellows ranged against him.

With the threat of possible jail time hanging over him in his ongoing trial on corruption charges, the 71-year-old is unlikely to allow his record 12 straight years to end without a messy fight, analysts warned.

On Thursday, the master political operator was already on Twitter, seeking to play on any last-minute misgivings among right-wing lawmakers about allying with the left against him.

Supporters of Israel's "change coalition" celebrate on the streets of Tel Aviv
Supporters of Israel's "change coalition" celebrate on the streets of Tel Aviv AFP / JACK GUEZ

"All lawmakers who were elected with votes from the right must oppose this dangerous left-wing government," he said.

On Twitter, Netanyahu's Likud party called on former right-wing allies to "immediately withdraw" their signatures.

Israeli Prime Minister Benjamin Netanyahu attends a special session of the Knesset, Israel's parliament
Israeli Prime Minister Benjamin Netanyahu attends a special session of the Knesset, Israel's parliament POOL / RONEN ZVULUN

The new coalition would see the religious-nationalist Naftali Bennett serve as prime minister for two years before Lapid, a secular centrist, would take the helm.

Should last-minute defections scupper the "change" alliance, Israel would likely have to hold yet another election, the fifth in just over two years.

"Opening the champagne right now is a bit hasty," said Tamar Hermann, a political scientist at the Israel Democracy Institute.

Naftali Bennett from the Yamina party
Naftali Bennett from the Yamina party POOL / RONEN ZVULUN
Unlikely bedfelllows - Arab Israeli Raam Mansour, leader of the Islamic conservative party Raam, signs the coalition agreement with opposition leader Yair Lapid and Jewish settler champion Naftali Bennett
Unlikely bedfelllows - Arab Israeli Raam Mansour, leader of the Islamic conservative party Raam, signs the coalition agreement with opposition leader Yair Lapid and Jewish settler champion Naftali Bennett United Arab List Raam / -

Lapid, 57, a former TV presenter who heads the centrist Yesh Atid party, put his own prime ministerial ambitions on hold to broker the coalition deal.

"I succeeded," he proclaimed, less than an hour before the deadline.

"I promise that this government will work in the service of all of the citizens of Israel, those who voted for it and those who did not," he wrote on Facebook.

Timeline of main developments in Israel's political deadlock in 2019.
Timeline of main developments in Israel's political deadlock in 2019. AFP / Gal ROMA

The announcement capped four frenzied weeks of negotiations since President Reuven Rivlin tasked Lapid with trying to form a government after Netanyahu failed.

Bennett, 49, an estranged former protege of Netanyahu, was the linchpin of the deal to unseat him.

Fans of Israeli Prime Minister Benjamin Netanyahu gather in Tel Aviv for a defiant rally in his support
Fans of Israeli Prime Minister Benjamin Netanyahu gather in Tel Aviv for a defiant rally in his support AFP / JACK GUEZ

On Sunday, Bennett, head of the far-right Yamina bloc, announced he would join Lapid to end the "madness".

On the right, the new coalition includes the hawkish New Hope party of Netanyahu's former ally Gideon Saar, and secular nationalist Avigdor Lieberman's Yisrael Beitenu party.

Also part of the alliance are the Labor party, the dovish Meretz party, and the centrist Blue and White party of Defence Minister Benny Gantz.

For the first time in Israeli's history, the embryonic coalition also includes an Arab Israeli party, the Islamic conservative party Raam.

It released pictures of its leader Mansour Abbas signing a coalition agreement alongside Bennett, a staunch supporter of the Jewish settler movement.

Speaking on army radio Thursday, Abbas said: "We obtained the legitimacy to influence the Israeli political system and not just to be present there in the Knesset."

Raam previously ran as part of the Arab-led Joint List but broke away over differences with its communist and Arab nationalist members. Joint List lawmaker Aida Touma-Sliman said she would oppose the new deal because "getting rid of Netanyahu and keeping his path is a political mistake."

Allies of Netanyahu lashed out at the coalition.

Far-right lawmaker Bezalel Smotrich, head of the Religious Zionism party, attacked the coalition's dependence on the votes of Arab lawmakers and accused Bennett of cooperating with "a terrorism supporter who identifies with Israel's enemies".

Yamina member Matan Kahana hit back, telling public radio: "I'm convinced this government will be even more right-wing than the government of Netanyahu."

Netanyahu's son Yair called Bennett "filth" in a tweet.

Netanyahu biographer Ben Caspit predicted the incumbent would fight the new government tooth and nail, doing everything he could to block its formation and then battling it from the opposition benches if necessary.

Caspit said Netanyahu could try to emulate his ally, former US president Donald Trump, who gave an incendiary address to supporters before they launched a deadly raid on the US Capitol.

"He is trying to burn it all," Caspit said of Netanyahu. "He still thinks he will succeed against all odds."

Washington on Thursday assured it would remain a staunch ally of the Jewish state regardless of who is in power.

"Regardless of what happens, regardless of what government is in place, our stalwart support, our ironclad support for Israel will remain," State Department spokesman Ned Price said.