Palestinian protesters face Israeli soldiers during clashes near the West Bank city of Nablus on Aug. 15. Photo: AP

Israelis and Palestinians agreed Monday to a 24-hour extension to a temporary ceasefire just minutes before it was due to expire, allowing for more time to hammer out a long-term truce, officials said.

Both sides will discuss draft proposals for a long-term ceasefire in talks brokered by Egypt, according to a Palestinian negotiator.

The latest extension was the second this week approved just before a midnight deadline.

It comes on the same day Israeli authorities announced they foiled a large-scale plot by Hamas groups in the West Bank to topple the Palestinian Authority.

Hamas headquarters in Turkey, which orchestrated the terrorist plot, hoped widespread attacks in Israel would weaken the authority so that militants could stage a coup and overthrow Palestinian President Mahmoud Abbas, the Jerusalem Post reported.

“The terrorists planned to undermine security and launch a third intifada,” a source with the security agency Shin Bet told the newspaper.

The Hamas cell in Gaza had no involvement in the plot, sources told the Jerusalem Post.

Shin Bet said the plot was thwarted in the early stages but that some of the attacks were planned to take place in recent weeks to open up a second front of fighting amid the conflict in Gaza.