JERUSALEM — Israeli Prime Minister Benjamin Netanyahu and his allies worked furiously Monday to keep opposition parties from forming a government that would displace him from Israel's top political job for the first time in more than 12 years.

Netanyahu backers slammed right-wing parties planning to join the broad-based coalition as “traitors,” picketed their homes and issued threats that led police to provide additional security to at least two of the targeted politicians.

The pressure came as members of the coalition finalized their agreement to form a power-sharing government that would include former Netanyahu allies, centrists and liberals, and even the indirect support of an Arab Islamist party. The arrangement, which could come up for a vote by the full parliament within the week, would potentially end more than two years of political stalemate in which no faction has been able to secure a governing majority after four inconclusive elections.

Negotiators for the anti-Netanyahu parties achieved a breakthrough Sunday when former defense minister and Netanyahu ally Naftali Bennett announced that he was joining the “change coalition” being assembled by former TV news anchor and centrist politician Yair Lapid. In exchange for his Yamina party’s six Knesset seats, Bennett would become Israel’s prime minister for a set number of years before Lapid takes over for a turn of his own, according to reports on the agreements in Israeli media.

Bennett would be Israel’s first religious prime minister. He has advocated for annexation of the West Bank and East Jerusalem, which Israel has occupied since the 1967 war. But in his role as prime minister in a mixed government, he would be unlikely to translate those ideological views into official policy, analysts say.

Talks to finalize the deal, including the apportionment of ministries among more than half a dozen participating parties, went until 3 a.m. Monday, media reports said, and party leaders said they expected to present a formal proposal to Israeli President Reuven Rivlin in the coming days.

Lapid’s mandate to form a government expires at midnight Wednesday, but he would have up to a week for the Knesset to vote on the coalition agreement.

Netanyahu reacted with outrage at Bennett’s move, accusing his former protege of committing “the fraud of the century” in televised remarks Sunday night. Netanyahu supporters branded Bennett and his fellow party leader Ayelet Shaked, a former justice minister, as betrayers of their right-wing voters, saying they would usher in a resurgence of Israel’s long-diminished left wing.

“Hearing Bennett’s words made every right-wing stomach churn,” commentator Mati Tuchfeld wrote in the right-wing, pro-Netanyahu newspaper Israel Hayom. “Every word in his speech was like a punch in the gut to the people who had believed him and had followed his lead.”

Small groups of protesters gathered at the two party leaders’ homes Sunday. Some carried signs reading “Treasonous leftists” in front of Shaked’s residence in Tel Aviv and Bennett’s in the central Israeli city of Raanana. In response, Knesset security officials and police arranged for them to be accompanied by an extra protective detail, according to Kan radio.

Lapid said he, Bennett, Shaked, Israel’s attorney general and several Israeli journalists who have been covering the political developments had all received death threats as a result of Netanyahu’s incitement.

“A country that is divided and violent won’t be able to deal with Iran or with the economy,” he said. “A leadership that incites us against one another harms our ability to deal with the challenges we face.”

“Political opponents from the left are not our enemies,” said Gideon Saar, another former Netanyahu ally and member of the change coalition. “There is an incitement machine that is running even before this government did anything, an incitement machine that has nothing to do with ideology, but only with anxiety about the loss of power.”

The campaign to pressure the more conservative politicians in the new coalition is likely to continue up until the last minute, according to political analysts. Netanyahu, who is standing trial on corruption charges in a Jerusalem court, is desperate to stay in office as a potential shield from his legal woes, they said.

While he has been unable to form a government of his own, derailing the opposition efforts would probably lead to a fifth election, buying him time, at the least. His best hope is making one of the right-wing coalition partners cave under the criticism.

“Knowing Netanyahu, he won’t give up until the fat lady sings,” said Aviv Bushinsky, a political commentator and former Netanyahu aide. “There is still a week. Netanyahu will keep up the pressure, particularly on Shaked.”

Many of Netanyahu’s fellow ­Likud members are pinning their hopes on the prime minister’s reputation as a political trickster, said Bushinsky, who has been in touch with several leaders of the party in recent days. They note that Netanyahu has staved off apparent defeat with bold moves in the past, including dissolving parliament in 2018 rather than let his rivals form a government.

“They hope he still has some tricks in his sleeve,” Bushinsky said. “It’s a combination of wishful thinking and precedent. He has done it before.”

Several complications could still cause the new coalition to collapse. If any of the parties back out, the razor-thin majority would be lost. Among them is the Blue and White party headed by Benny Gantz, who split with Lapid last year and joined forces with Netanyahu to address the coronavirus crisis.

Gantz told reporters Monday he “would do everything in my capacity to help” Bennett as prime minister. And he rejected claims by Netanyahu that the proposed government would lack the security experience to stand up to Hamas in Gaza, to Hezbollah in Lebanon and to Iran. He noted that half of the new security cabinet would consist of ministers who had served in the decision-making body previously.

“There has not been a security event in the last four decades that I was not part of,” said Gantz, who is expected to stay in his current role as defense minister.

The deal will also apparently depend on support from a small Islamist party, Ra’am, whose leader has not yet formally signed on to either vote for the coalition or abstain, either of which would allow the new government to form.

But so far, Netanyahu’s efforts to turn out mass resistance to the proposed government have failed to produce big crowds. The protesters have numbered in the dozens, not thousands, according to media reports.

“Usually, the right-wingers are more vocal; they are the ones that can block the streets. But he has failed to motivate them,” Bushinsky said. “There’s a lot of fatigue. We’ve been talking about politics for two and a half years now.”

Even some members of Likud have come to see Netanyahu as more of a liability than an asset and have encouraged him to step aside to allow Likud to regain its political capital, according to Israeli media. On Sunday, Likud politician and Netanyahu devotee Israel Katz said he had offered to replace Netanyahu as prime minister for one year, to have the chance to form a right-wing government. Netanyahu refused the offer, Katz said.

The possibility of a non-Netanyahu government has become real enough for Israelis to ponder how the change coalition would actually run the country, and whether such an ideologically mixed assemblage could survive.

If approved, it would be Israel’s second attempt to break the political impasse with a “unity” government of differing factions. The power-sharing deal brokered last year between Netanyahu and Gantz lasted only seven months and never managed to pass a budget before collapsing amid acrimony. Critics accused Netanyahu of facilitating its collapse to force another election, thereby keeping Gantz from taking his turn as prime minister.

This time, the parties, while politically mismatched, are unified by two overriding desires: to oust Netanyahu and to finally halt Israel’s nonstop election merry-go-round.

“One would expect an unstable government,” said Yohanan Plesner, president of the Israel Democracy Institute. “There’s no ideological cohesion. But there are factors that would contribute to keeping it together, mainly, that no members have an interest in going for another election.”

The political differences mean that the new government would likely stick to consensus issues, such as healing Israel’s post-covid economy, analysts said. Lawmakers would probably avoid major policy shifts on hot-button or unpopular issues, such as the expansion of settlements in the West Bank or the renewal of negotiations with the Palestinians.

The defense and security apparatus would probably maintain the country’s posture toward Hamas, Hezbollah and Iran, said Reuven Hazan, a political scientist at Hebrew University in Jerusalem.

“But while the unity government can try to deal with issues they agree on, at some point the conflict will come back,” Hazan said. “If there’s one thing the conflict teaches you, it’s that it will never go away and probably come at the worst possible time.”

Rubin reported from Tel Aviv.