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.
Within minutes of the announcements, in the countdown to the ceasefire, the sides were trading blows again. Sirens warned of incoming rockets in Israeli border communities, and a Reuters reporter heard an air strike in Gaza.
There was no immediate word of casualties.
Amid growing global alarm at the bloodshed, U.S. President Joe Biden urged Netanyahu on Wednesday to seek de-escalation, while Egypt, Qatar and the United Nations sought to mediate.
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".
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 saw 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 Hanegi told Israel's top-rated Channel 12 TV earlier on Thursday.
Biden discussed Gaza with Sisi and the White House said reports of moves toward a ceasefire were "encouraging". 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.