This is an archived article and the information in the article may be outdated. Please look at the time stamp on the story to see when it was last updated.

JERUSALEM (AP) — Prime Minister Benjamin Netanyahu’s opponents on Wednesday were racing to finalize a coalition government to end his 12-year rule — the longest by any Israeli premier — ahead of a midnight deadline.

Centrist Yair Lapid and ultranationalist Naftali Bennett have joined forces and agreed to rotate the premiership between them, with Bennett going first, but are still working to cobble together a ruling coalition that would include parties from across the political spectrum.

Israeli media reported that there are some lingering disagreements over lower-level political appointments but that Lapid was likely to announce an agreement sometime Wednesday.

He faces a midnight deadline to inform Israel’s largely ceremonial President Reuven Rivlin that he has formed a majority coalition of at least 61 seats in Israel’s Knesset, or parliament. The assembly would then have a week to hold a vote of confidence.

If Lapid misses the midnight deadline, the country will almost certainly go into a fifth election in just over two years, and Netanyahu would have yet another chance to hold onto his position as he stands trial for corruption.

Netanyahu’s Likud won the most seats in the March 23 election, but he was unable to form a majority with his natural allies. Crucially, a far-right party allied with Netanyahu refused to join forces with a small Arab party that emerged as a kingmaker of sorts.

Netanyahu had hoped to extend his long rule and battle the corruption charges from the prime minister’s office. He has emerged as a deeply polarizing force in recent years, leaving Israel in a prolonged state of political limbo through a series of inconclusive elections.

An emergency government formed last year between Netanyahu and former military chief Benny Gantz to battle the coronavirus pandemic quickly became mired in political bickering and collapsed in December. That government remains in place as caretaker.