A ceasefire took effect in and around the Gaza Strip on Saturday after five days of cross-border exchanges that have killed at least 33 Palestinians in Gaza and two people in Israel.
The truce was due to take effect at 10pm local time (1900 GMT), Egyptian and Palestinian sources said.
But in the final 30 minutes running up to 1900 GMT, dozens of rockets were fired from Gaza towards Israel, prompting renewed air strikes, AFP correspondents in the territory said.
Most of the rockets were intercepted by Israeli air defences.
A few more rockets were still fired after 1900 GMT, followed by fresh Israeli strikes before things appeared to calm down.
Hundreds of people then began to emerge into the streets of Gaza, after days during which they have been empty.
Two rockets were fired from Gaza after 11pm local time with no victims, the Israeli army said.
Egypt, a longtime mediator in Gaza, secured the agreement of both Israel and Palestinian militant group Islamic Jihad to its latest ceasefire proposal, an Egyptian security official said.
"Israel's National Security Adviser Tsahi Hanegbi... thanked Egyptian President Abdel Fattah al-Sisi, and expressed the State of Israel's appreciation for Egypt's vigorous efforts to bring about a ceasefire," a statement from the Israeli prime minister's office said.
Israel's response to the Egyptian initiative means "quiet will be answered by quiet, and if Israel is attacked or be threatened it will continue to do everything it needs to do in order to defend itself", he said.
A Palestinian source confirmed Islamic Jihad's agreement.
"We want to thank Egypt for its efforts," Islamic Jihad political department official Mohammad al-Hindi told AFP. He has been in Cairo since the fighting erupted on Tuesday.
On Saturday, Israel had again pounded Gaza with air strikes targeting Islamic Jihad following a new barrage of rocket fire into Israel to mark the funeral of its military commander Iyad al-Hassani, who was killed on Friday.
'What have we done?'
For days, life in Gaza and in Israeli communities near the border has been a daily routine of air strikes and sirens warning of incoming rocket fire.
Residents in the crowded Gaza Strip cowered indoors as the fighting raged, with streets empty and only a few shops and pharmacies open.
"The whole Palestinian people are suffering," Muhammad Muhanna, 58, told AFP in the ruins of his home. "What have we done?"
In Deir al-Balah in the central Gaza Strip, a dead donkey lay in the ruins of a row of buildings levelled in an Israeli strike.
"No one is safe in their homes," said Imad Rayan, 64.
A spokesman for the interior ministry in Gaza said on the final day of its campaign the Israeli military had concentrated on "targeting civilians, residential and civilian buildings".
There had been mounting calls for a ceasefire to be agreed, including from Israel's closest ally, the US.
US Deputy Secretary of State Wendy Sherman, in a call to Israeli Strategic Affairs Minister Ron Dermer, "stressed the urgency of reaching a ceasefire agreement in order to prevent any further loss of civilian life", the State Department said.
Egypt had kept up its mediation effort despite repeated setbacks.
On Saturday, shrapnel from a rocket fired from Gaza hit a building site in Sdot Negev, just over the border into Israel, killing one man and wounding another. Both were day labourers from Gaza.
Islamic Jihad said its fighters were pursuing "missile strikes on Israeli cities" in revenge for Israeli "assassinations" of their commanders and strikes on populated areas.
The exchange of fire came after the Palestinian health ministry reported the death of two men aged 19 and 32 in an Israeli army raid on a refugee camp in the occupied West Bank city of Nablus.
The Fatah movement of Palestinian president Mahmud Abbas said the two men killed in the raid were members of its armed wing, the Al-Aqsa Martyrs Brigades.
Deadliest fighting since August
The current bout of violence erupted on Tuesday when Israeli strikes on Gaza killed three leading Islamic Jihad members. Three other senior figures from the Palestinian militant group were killed in later strikes.
They are among at least 33 lives lost in the fighting inside Gaza, according to the territory's health ministry.
There have been two deaths in Israel, one of them the Gazan day labourer.
The army said nearly 1,100 rockets had been fired from Gaza towards Israel in the current fighting, including 300 intercepted by its air defences.
Gaza, a coastal enclave that is home to 2.3 million Palestinians, has been plagued by poverty and unemployment since Israel imposed a blockade in 2007 when the Islamist movement Hamas took control.
The territory has seen numerous wars between militant groups and Israel since the Hamas takeover.
This week's fighting was the worst in the Israeli-Palestinian conflict since an August flare-up that killed nearly 50 Palestinians.
The conflict has escalated since veteran Israeli politician Benjamin Netanyahu returned to power late last year, heading a coalition with extreme right and ultra-Orthodox parties.