JERUSALEM — Prime Minister Benjamin Netanyahu of Israel, who emerged from this week’s election poised to win a fourth consecutive term, may benefit from an effort by his right-wing coalition to protect him from prosecution on possible corruption charges.

At least one right-wing party expected to join his new governing coalition has been open about its goal of passing a law granting immunity to Israeli Parliament members, including prime ministers.

Mr. Netanyahu, who worked on Wednesday to consolidate support for a new coalition, is on track to become Israel’s longest-serving prime minister, but also the first to be charged with a crime while in office.

“If Netanyahu gains the public’s trust in the coming elections,” Bezalel Smotrich, leader of the Union of Right Wing Parties, wrote on Twitter last month, “it will be imperative to enact a law that will prevent him standing trial.”