Prime Minister Benjamin Netanyahu's opponents announced they have reached a deal to form a new governing coalition, paving the way for the ouster of the longtime Israeli leader.
The dramatic announcement by opposition leader Yair Lapid and his main coalition partner, Naftali Bennett, came moments before a midnight deadline and prevented the country from plunging into what would have been its fifth consecutive election in just over two years.
In a statement on Twitter, Lapid said he had informed the country's president of the deal.
"This government will work for all the citizens of Israel, those that voted for it and those that didn’t. It will do everything to unite Israeli society," he said.
Netanyahu's opponents had raced against the clock to finalise a coalition government that would end his 12-year rule ahead of a deadline at midnight Wednesday.
Centrist Lapid and ultranationalist Bennett joined forces and agreed to rotate the premiership between them, with Bennett going first.
By Wednesday night, less than two hours before the deadline at midnight (2100 GMT), there was still no deal.
In a sign of progress, Lapid announced a coalition deal with the United Arab List, a small Islamist party whose support is key to securing a coalition. The deal would make it the the first Palestinian party to be part of an Israeli governing coalition.
Mansour Abbas, leader of the United Arab List, said his party made the "difficult decision" to join Lapid's governing coalition.
"This is the first time an Arab party is a partner in the formation of a government," he told reporters. "This agreement has a lot of things for the benefit of [Palestinian] society, and Israeli society in general."
Parliament on Wednesday elected Isaac Herzog, a veteran politician and the scion of a prominent Zionist family, as the country's next president.
"We must defend Israel's international status and its good reputation in the family of nations, fight antisemitism and hatred of Israel, and preserve the pillars of our democracy," Herzog, whose late father held the same position, said after the votes were tallied.
Herzog, 60, is a former head of Israel's Labor Party and opposition leader who unsuccessfully ran against Netanyahu in the 2015 parliamentary elections.
His father, Chaim Herzog, was Israel’s ambassador to the United Nations before being elected president. His uncle, Abba Eban, was Israel’s first foreign minister and ambassador to the United Nations and United States. His grandfather was the country’s first chief rabbi.
Herzog is set to take office next month and could play a role in Israeli politics down the road.
The president's responsibilities include choosing the party leader in parliament he believes has the best chance of forming a coalition after each election. If the country is forced into another vote, Herzog could help determine who becomes prime minister.
The president also has the authority to grant pardons - making Herzog a potentially key player if Netanyahu, who is on trial for multiple corruption charges, is eventually convicted.