Israel and Hamas will cease fire across the Gaza Strip border as of Friday, the United States said, bringing a potentially tenuous halt to the fiercest fighting in years.
Israeli Prime Minister Benjamin Netanyahu's office said his security cabinet had voted unanimously in favour of a "mutual and unconditional" Gaza truce proposed by Egypt, but added that the hour of implementation had yet to be agreed.
Hamas and Egypt said the truce would begin at 2 a.m. (2300 GMT Thursday), after 11 days of Israeli-Palestinian hostilities.
In a televised address at 2200 GMT, US President Joe Biden said both sides agreed the truce would begin "in less than two hours".
The sides traded blows again in the countdown.
Sirens warned of incoming rockets in Israeli border communities, and a Reuters reporter heard an air strike in Gaza. A man in his 50s was lightly hurt in a direct hit on an Israeli factory, medics said.
Amid growing global alarm at the bloodshed, Biden had urged Netanyahu to seek de-escalation, while Egypt, Qatar and the United Nations sought to mediate.
Extending condolences to bereaved Israelis and Palestinians, Biden said Washington would work with the United Nations "and other international stakeholders to provide rapid humanitarian assistance" for the reconstruction of Hamas-controlled Gaza.
He said aid would be coordinated with the Palestinian Authority - run by Hamas' rival, President Mahmoud Abbas, and based in the Israeli-occupied West Bank - "in a manner that does not permit Hamas to simply restock its military arsenal".
The United States was also committed to replenishing Iron Dome interceptors that helped Israel fend off the more than 4,300 rockets fired at it from Gaza during the this month's conflict.
Hamas said the ceasefire would be "mutual and simultaneous".
"The Palestinian resistance will abide by this agreement as long as the Occupation (Israel) does the same," Taher Al-Nono, media adviser to Hamas chief Ismail Haniyeh, told Reuters.
Egyptian President Abdel Fattah al-Sisi had ordered two security delegations into Israel and the Palestinian Territories to work towards upholding the ceasefire, Egyptian state TV reported.
In a televised speech Abu Ubaida, spokesman of the Hamas armed wing, said: "With the help of God, we were able to humiliate the enemy, its fragile entity and its savage army."
He threatened Hamas rocket fire that would reach throughout Israel if it violated the truce or struck Gaza before the hour of implementation.
Rocket attacks by Hamas and the allied Islamic Jihad had resumed after an eight-hour pause earlier on Thursday, as Israel pursued shelling that it said aimed to destroy the factions' military capabilities and deter them from future confrontations after the current conflict.
Israeli Defence Minister Benny Gantz said on Twitter that the Gaza offensive had yielded "unprecedented military gains".
Speaking to his US counterpart Lloyd Austin, Gantz said Israel's defence establishment would "continue to work closely and in full cooperation with the Pentagon and the US administration to stabilise the region," Gantz's office said.
Since the fighting began on May 10, health officials in Gaza said 232 Palestinians, including 65 children, had been killed and more than 1,900 wounded in aerial bombardments. Israel said it had killed at least 160 combatants in Gaza.
Authorities put the death toll in Israel at 12, with hundreds of people treated for injuries in rocket attacks that caused panic and sent people rushing into shelters.
The violence was triggered by Palestinian anger at what they viewed as Israeli curbs on their rights in Jerusalem, including during police confrontations with protesters at Al-Aqsa mosque.
Hamas previously demanded that any halt to the Gaza fighting be accompanied by Israeli drawdowns in Jerusalem. An Israeli official told Reuters there was no such condition in the truce.
"The only way there'll be a Hamas-Jerusalem linkage is if they agree to us drowning them on 'Jerusalem Beach' in Tel Aviv," security cabinet minister Tzachi Hanegbi told Israel's top-rated Channel 12 TV earlier on Thursday.
Hamas is deemed a terrorist group in the West and by Israel, which it refuses to recognise.
The United Nations said its Middle East envoy, Tor Wennesland, was in Qatar on Thursday as part of truce efforts.