Israel’s parliament has voted in a new government, ending rightwing stalwart and five-time premier Benjamin Netanyahu’s 12-year grip on power after four elections and two years of political paralysis.

The vote marked a historic change in the Jewish state’s leadership, replacing its longest-serving prime minister with Naftali Bennett, an ultranationalist whose Yamina party controls just six seats in the 120-member Knesset.

Bennett will start his first premiership at the head of an eight-party coalition that stretches from the fringe left to the extreme right and is buoyed by support from an Islamist party. It will also be the first time in Israeli history that an Arab party will share power with a Zionist government. The coalition has a one-seat majority and political analysts were pessimistic about its long-term survival.

In his inaugural speech, Bennett warned that Israel’s political mud-slinging had weakened the country. “I am proud of the ability to sit together with people with very different views from my own,” he said, over jeers from Netanyahu’s allies, who called him a “criminal” and “liar”.

“To continue on in this way — more elections, more hatred, more vitriol on Facebook — is just not an option,” he added.

The ousting of Netanyahu marked at least an intermission in the reign of the 71-year-old rightwing standard bearer, who has led Israel for 15 of the past 25 years and is still the nation’s most popular leader despite failing to create a governing coalition.

After military service in the elite Sayeret Matkal unit, and a stint in the US, first in consulting and then at the Israeli embassy, Netanyahu kickstarted his political career in 1996 with a winning campaign against the Oslo Accords. He returned to office in 2009, when he clashed repeatedly with US president Barack Obama, first over the Palestinian issue and then over talks to curb Iran’s nuclear ambitions.

Netanyahu reaped the benefits of the Israeli right wing’s 40-year pursuit of support from US Christian evangelicals. Donald Trump moved the US embassy to Jerusalem, strengthening the Jewish state’s claim to the contested city, and in 2018 withdrew from the nuclear agreement that Iran had signed with world powers three years previously.

Iranians were celebrating Israel’s new “limp and weak government”, Netanyahu told the Knesset on Sunday, as he warned that Bennett would buckle to US pressure on issues ranging from settlements to renewing the nuclear deal.

“The public won’t forget this tremendous fraud,” he added, and mocked Bennett for his party’s six seats, calling the new leader “a prime minister standing at the head of a pin”.

The Netanyahu years were marked by his race-baiting attacks on the Palestinian citizens of Israel and his villainisation of the Israeli left as traitors to Zionism. His rule accompanied a swing to the right for the majority of Israelis and leaves a legacy of acrimony that Bennett has vowed to repair. Netanyahu called plans for a term-limit law that would exclude him from running again “fascist”.

The long-serving leader enters opposition as a criminal defendant in a trial on three charges of corruption. He has pled not guilty to all charges and has rejected the trial as a politically motivated witch hunt designed to end his premiership

Bennett, a 49-year-old tech millionaire who bills himself as more rightwing than Netanyahu, will be premier for two years, after which he is expected to step down to make way for Yair Lapid, a former TV anchor who runs the centrist Yesh Atid and pulled the coalition together to oust Netanyahu. The alternate prime minister abandoned his own speech because of the heckling.

For Israelis, who have gone through four elections since April 2019 — three of which ended in a stalemate, while one yielded a shortlived unity government — the vote signals at least a short intermission to political gridlock.

But political analysts were already forecasting the coalition’s demise over a wide variety of disagreements, including gay rights, the rights of Palestinian citizens of Israel and even the rights of non-Orthodox Jews to marry freely.

Coalition building among Netanyahu’s rivals was interrupted by a fortnight of communal strife within Israel, accompanied by an 11-day aerial bombardment of the Gaza Strip to contain the Palestinian militant group Hamas and widespread revolts in the occupied West Bank.

Opposition leaders — four of the parties are run by people Netanyahu personally groomed, then betrayed in one way or another — pulled together the coalition with just 38 minutes to spare before a deadline that would have triggered fresh elections.

It includes the Ra’am Islamist party, which represents the traditional Muslim vote among the 2m Palestinian citizens of Israel. It is joining the government in exchange for billions of dollars of investment for one of the most impoverished sections of Israeli society.