JERUSALEM — In the lead-up to recent Israeli elections, Prime Minister Benjamin Netanyahu repeatedly denied that he would seek legislation that would give him immunity from prosecution in three criminal cases against him.

When asked what he’d do if his political allies did so on his behalf, he was more evasive, distancing himself from their actions.

Late Monday night, that’s just the scenario that emerged, as Israel’s parliament, known as the Knesset, announced that the “immunity bill,” filed by a Netanyahu loyalist, was among 200 measures slated for a vote in the current session.

A draft of the bill says members of the 120-seat Knesset cannot be charged with a criminal offense committed during or before being voted in as a Knesset member unless a house committee and the wider body both waive immunity. As prime minister, Netanyahu is a Knesset member.

Alongside proposals to roll back the powers of the Israeli Supreme Court to overturn bills passed by the Knesset, the immunity legislation has drawn sharp rebuke from Netanyahu’s rivals, including some within his own party, who accuse the longtime Israeli leader of sliding toward authoritarianism in order to avoid prosecution. Israel’s attorney general, Avichai Mandelblit, announced in February that he would proceed with the indictment process against Netanyahu on charges that include breach of trust, corruption and bribery.

The furor over efforts to shield Netanyahu from prosecution echoes the debate in the United States, where the question of whether a leader can be indicted has also been a contentious issue. Justice Department guidelines state that a sitting U.S. president should not be indicted; consequently, special counsel Robert Mueller decided not to come to a determination on whether President Donald Trump obstructed justice. Mueller instead laid out evidence on both sides of the issue in his final report.

Like Trump, Netanyahu says the accusations against him are due to a politically motivated “witch hunt,” and he denies them. But Israeli police deemed that there was enough evidence against Netanyahu to refer three cases against him to Mandelblit, a former Cabinet minister for Netanyahu, who has indicated that he plans to proceed with charges, pending the outcome of a hearing in which the prime minister can present his defense.

Despite the allegations, Netanyahu’s Likud party scraped a one-seat victory over its main opponent in April elections and had a clear advantage when it came to building a coalition government with its traditional partners of right-wing and ultra-Orthodox religious parties.

Still, that has been no easy feat, with Netanayhu granted a two-week extension to the 28-day deadline to form a new government as he bargains with his coalition partners over ministerial seats and legislative promises. With ministerial portfolios doled out in exchange for support, Knesset members on Monday evening voted to advance legislation that would expand the number of Cabinet posts, amid expectations that Netanyahu will announce an unusually large Cabinet.

“We are on a slippery slope,” said Dan Avnon, chairman of the political science department at Jerusalem’s Hebrew University, referring to the immunity bill. “It would mean the house of representatives becoming an asylum for prospective criminals.” The legislation, as well as the proposal to curb courts’ oversight role, is “anti-democratic and undermines a parliamentary democracy,” he added.

A cartoon circulated online showed Netanyahu and other politicians accused of corruption running toward the Knesset, marked with a “shelter” sign. The legislation would exclude traffic violations and criminal charges that lead to fines, but it would allow immunity for any other criminal offense.

Miki Zohar, the Knesset member who submitted the bill last month, said that it was formally lodged onto the Knesset system “to my delight.”

The bill would effectively reverse the current procedure, under which immunity can be granted to a Knesset committee member only if a house committee and the full parliament agree. If the bill is adopted, Mandelblit could only proceed with the prosecution if he wins the approval of the committee, which Zohar is expected to head in the new parliamentary session, and then of a majority of the Knesset.

Speaking to a Knesset committee on Tuesday, Zohar denied that he was an “emissary” for Netanyahu, and added that the Israeli leader had said that he wasn’t interested in an immunity law. He also denied that support for the legislation was part of coalition building discussions.

However, many are not convinced. Gideon Sa’ar, a senior member of Likud with a fractious relationship with Netanyahu, has broken ranks with his party to criticize the Israeli leader’s bid for immunity.

“This legislation offers zero benefit and maximum damage,” he told Israel’s Channel 12. Michal Shir, Sa’ar’s former aide and a newly elected Knesset member, has also spoken out.

Former Likud Knesset member Benny Begin was also stinging over efforts to grant Netanyahu immunity, telling Israeli television that “such a phenomenon is called corruption.”

The Blue and White party, which holds 35 seats in the newly formed Knesset, making it the second largest in the chamber, is holding a protest rally in Tel Aviv on Saturday under the banner “Defense shield for democracy.”

“There is no reason whatsoever to bring out such far-reaching constitutional amendments in such a rush unless it was connected to the fate of the prime minister,” said Yohanan Plesner, president of the Israel Democracy Institute. He said that the specifics of legislation intended to weaken the Supreme Court remain unclear, but without it the immunity law will be “meaningless.”

“It is highly unconstitutional and the court will override it immediately,” he said. On Monday dozens of top lawyers gathered in Tel Aviv to protest those efforts.

“We don’t know how each of us here votes politically, and in our daily lives we are competitors, but we’re all gathered here today, united by a tangible fear that the rule of law and Israel’s liberal democracy are in danger,” attorney Tzvika Bar Natan, a partner at Goldfarb Seligman who initiated the campaign, told the Time of Israel.