JERUSALEM — For the first time in 12 years, Israeli lawmakers voted Sunday to install a government led by someone other than Benjamin Netanyahu, breaking a two-year electoral deadlock, marking a likely shift toward the political center and ending — for now — the reign of the country's longest-serving prime minister, and one of its most consequential.

A raucous parliament, interrupted frequently by shouts of “shame” and “liar” from outgoing conservative lawmakers, voted by the narrowest of margins — 60 to 59 — to give power to an unlikely coalition of parties from the right, center and left of Israel’s spectrum. The votes elevated Naftali Bennett, an Orthodox leader of Israel’s religious-nationalist movement and a former Netanyahu ally, as the country’s new prime minister.

“We are incapable of sitting together — what is happening to us?” Bennett pleaded before the vote over boos and catcalls as his own children flashed him heart symbols from the visitors’ gallery. “I am proud of sitting with people who have very different opinions. We have decided to take responsibility.”

Several conservative members were ejected from the session. They included extremist right-wing lawmaker Itamar Ben-Gvir, a disciple of the banned Kahane Party who was elected to the Knesset with help from Netanyahu.

Under the coalition’s power-sharing deal, Bennett is to be replaced in the top job after two years by Yair Lapid, a centrist politician and former TV news anchor who clinched the second largest number of votes after Netanyahu’s Likud party in March.

Lapid brokered the power-sharing deal among eight parties with little in common beyond a determination to end the contentious rule of Netanyahu, who has clung to power despite being on trial for corruption and failing to secure a majority after four inconclusive elections in two years.

Lapid scrapped his own speech and instead apologized to his 86-year-old mother for the heckling.

“I assumed you would be able to get over yourselves,” Lapid told his fellow lawmakers. “Instead, she and every other Israeli citizen is ashamed of you and reminded why it’s time for you to be replaced.”

The government breaks new ground by including the first independent Arab party to sign on to an Israeli governing coalition. The Islamist Ra’am party, which was courted by both Netanyahu and Lapid, has demanded new programs and spending for Arab citizens of Israel, who account for about 20 percent of the population.

Meanwhile, ultra-Orthodox parties will not be part of the government for the first time, with two brief exceptions, since 1977. Their absence, after forming an unshakable foundation for Netanyahu’s governments, could endanger the controversial grip of ultra-Orthodox rabbis on religious and family law and the community’s exemption from compulsory military service.

Netanyahu delivered a bellicose parting shot to Bennett and his allies, belittling the coalition as incapable of maintaining his record of economic growth, relative peace and standing up to U.S. pressure to acquiesce to a renewed nuclear deal with Iran.

“I’ll be back,” Netanyahu told lawmakers. “Try to ruin our wonderful economy as little as possible so we can fix it as quickly as possible when we return.”

Netanyahu compared the Biden administration’s push to renew the Iran deal to the U.S. failure during World War II to bomb the Nazi trains that took European Jews to the gas chambers.

“Bennett hasn’t got the international standing, the integrity, the capability, the knowledge and he hasn’t got the government to oppose the nuclear agreement,” Netanyahu said. “An Israeli prime minister needs to be able to say no to the leader of the world’s superpower.”

President Biden spoke with Bennett after the vote to offer his “warm congratulations,” the White House said.

“My administration is fully committed to working with the new Israeli government to advance security, stability, and peace for Israelis, Palestinians, and people throughout the broader region,” Biden said in a statement. He didn’t mention Netanyahu. 

The new government ends 12 consecutive years of Netanyahu rule, a period during which Israel has enjoyed a flourishing tech boom, relative quiet on the country’s periodically explosive fronts from Lebanon to Gaza, and no return of a general Intifada among Palestinians of the West Bank. A 12-day air war with Hamas in Gaza last month was thought likely to derail the new coalition, but the parties resumed negotiations almost immediately after a May 21 cease-fire.

But the tenure of Netanyahu, who also served as prime minister for three years in the 1990s, also produced political tumult that has dragged increasingly disillusioned and exhausted Israelis through an unprecedented cycle of elections, stalemate and acrimony.

Although Netanyahu’s Likud party won the most votes in three of the four elections since April 2019, his usual coalition of ultra-Orthodox and nationalist parties failed to secure the majority needed to form a government. Netanyahu has remained atop a caretaker government that has been largely paralyzed since the end of 2018. Even a short-lived emergency unity government that formed last year in the midst of the coronavirus pandemic failed to pass a budget.

As the government remained effectively frozen, Netanyahu was indicted and began a trial on charges of bribery, fraud and breach of trust that has further divided an acutely polarized Israel.

Netanyahu’s devoted base of supporters echo his claims that a politically biased deep state has concocted a witch hunt against him. On the other side of the divide are those who say his attacks on the judiciary, demonization of opponents and refusal to step aside are corroding institutions and Israel’s rule of law.

Tensions spiked in the run-up to Sunday’s vote, sparking fears of violence in a country still raw from the 1995 assassination of Prime Minister Yitzhak Rabin by a right-wing extremist.

Netanyahu called the new coalition a “dangerous, left-wing government.” Religious-nationalist rabbis called on supporters to “do anything” to prevent it from taking power.

Protesters demonstrated outside of lawmakers’ homes; death threats spurred police to assign them security details.

Israel’s Shin Bet, the internal security service, issued a rare warning last week that the uptick in incitement could turn lethal.

In the midst of surging hostilities, Bennett said in recent interviews that his government will not seek to change policy on hot-button issues such as Israeli settlements in the West Bank, state benefits granted to ultra-Orthodox families or peace with Palestinians. He and Lapid, as they take turns in the role of prime minister, will effectively have veto power over each other’s major initiatives, which will in theory limit the government to consensus actions. They have pledged to approve a budget within 140 days.

While Likud lawmakers expressed hope for a last-minute collapse of the coalition, some began gingerly to jockey for leadership in a post-Netanyahu party. Health Minister Yuli Edelstein has reportedly begun testing his support; former Jerusalem mayor Nir Barkat held an event for 5,000 Likud activists last week. Barkat said he is only preparing in case Netanyahu decides to retire, something the 71-year-old has not announced.

Protesters of Israel's Benjamin Netanyahu demonstrated in Jerusalem on June 13 and reacted with joy as parliament approved a new governing coalition. (Reuters)

Political observers say Netanyahu’s continued presence in parliament as leader of the opposition could help the new government, given that aversion to his bellicose style is the glue that holds the coalition together. In any case, Netanyahu’s Likud and his allies enter the minority as practiced and well-organized opponents of the fledgling government.

“We are going to be the most ferocious opposition that Israel has ever known,” Likud faction chairman Miki Zohar told the daily newspaper Maariv. 

The new government launches at a time of flaring sectoral tensions at home and looming threats abroad. The new ministers face an immediate challenge Tuesday, when a planned march by Jewish nationalists through Arab areas of Jerusalem’s Old City could spark a resumption of clashes with Palestinians.

Israel, with Egyptian brokers, is also negotiating a longer-term cease-fire with Hamas in hope of preventing a return to the fighting that killed almost 250 Gazans and 12 Israelis.

The incoming security and diplomatic teams — led by returning Defense Minister Benny Gantz and Lapid, who will serve two years as foreign minister — are watching uneasily as Washington pushes for a renewed Iran deal, a move strongly opposed in Jerusalem. Israel’s new mission in Washington will be tasked with repairing strained relations with the Biden administration and Democratic majorities in Congress left behind by Netanyahu’s tilt in recent years toward Republicans.

The reported details of the coalition agreement include a measure that would limit the term of future prime ministers to two terms, or eight years, which would prevent future runs such as Netanyahu’s record-setting 15 years. The lawmakers could also consider barring departing prime ministers for a four-year “cooling-off” period before they run again, outraging Netanyahu’s supporters.