Israel’s opposition leaders have agreed to form a government that could potentially end Benjamin Netanyahu’s 12-year reign as prime minister of the Jewish state.

The coalition, which straddles the political spectrum — from the far-left Meretz party to the ultranationalist Yamina, anchored by centrists Yesh Atid — hammered out a deal on Wednesday after days of frantic negotiations.

The so-called change government will be supported by Ra’am, an Islamist party that is playing the role of a tiebreaker after four elections in two years failed to deliver a clear result. It is only the second time in Israeli history that an Arab party will play a role in a Zionist government, and the first time one has officially joined a coalition.

This disparate grouping shares a single common goal: the removal of Netanyahu, Israel’s longest-serving PM, currently on trial for corruption, from office. Netanyahu denies all charges.

“This government will work to serve all the citizens of Israel including those who aren’t members of it, will respect those who oppose it, and do everything in its power to unite all parts of Israeli society,” Yair Lapid, the leader of Yesh Atid, wrote to the president.

Lawmakers will now vote on the government in about 10 days. Analysts warn that the coalition, which has a razor-thin majority of 61 out of 120 seats, might still fail to secure enough votes. Should they fail, Israel will face its fifth election in just over two years.

If it passes, Naftali Bennett, a tech millionaire who is more rightwing than Netanyahu and controls just six seats in the 120-member Knesset, is set to become the next prime minister.

Bennett, 49, is a former protégé of Netanyahu’s who worked as his chief of staff and then defence minister. He is ideologically opposed to the creation of a Palestinian state and previously clashed with Netanyahu for not coming down harder on Hamas, the militant group that controls the Gaza Strip.

He has lobbied for Israel to annex swaths of the occupied West Bank and championed expanding Jewish settlements, considered illegal by most of the international community.

In two years, he will then step down, and Lapid, an ex-television presenter who runs the middle-class-focused Yesh Atid, will rotate into the premiership.

Negotiations were held up as Bennett’s party, Yamina, haggled over control of a panel that appoints judges. His political partner, Ayelet Shaked, has vowed to continue her “Legal Revolution”, designed to reduce the influence of the Supreme Court, and will rotate a spot on the judicial appointments committee with Labor party leader Merav Michaeli.

Ra’am’s support is conditional on material benefits for Israel’s Muslim minority community, including more money for police, a hospital and other civic amenities. Israeli media reported Ra’am’s leader Mansour Abbas asked for changes to a law that mandates jail time for building permit violations, an issue that disproportionately affected Palestinians with Israeli nationality, according to human rights groups.