Israeli forces unleashed a wave of deadly strikes across the Gaza Strip on Friday after a soldier was shot dead along the border.
A ceasefire agreement was reached early Saturday after Egyptian and United Nations mediation, a spokesman for Gaza's Islamist rulers Hamas said, reducing fears of a wider conflict.
On Friday, three Hamas militants were killed as air raids sent fireballs exploding into the sky over Gaza, while Israel said rockets had been fired back at its territory.
The United Nations urged all sides to step "back from the brink" after months of increasing tensions, with a fourth Palestinian shot dead during protests along the border with Israel.
The flare-up is the latest as demonstrations and clashes on the frontier since March have seen at least 149 Palestinians killed.
The soldier was the first Israeli killed in that time.
The army said "a terrorist squad shot" him on the border with southern Gaza, without naming him.
A spokesman told AFP it was the first time an Israeli soldier had been killed in or around Gaza during operations since the most recent war in 2014.
The United Nations envoy for the Middle East peace process, Nickolay Mladenov, said "everyone in Gaza needs to step back from the brink. Not next week. Not tomorrow. Right NOW!"
"Those who want to provoke Palestinians and Israelis into another war must not succeed," he wrote on Twitter.
Later Hamas spokesman Fawzi Barhoum said the UN and Egypt had helped negotiate a ceasefire, with an agreement reached "to return to the previous state of calm between the (Israeli) occupation and the Palestinian factions".
Israel did not confirm the deal, which was the second such ceasefire agreement in a week.
Earlier the Israeli military said its aircraft and tanks targeted 40 Hamas posts and that the strikes formed part of a "wide-scale attack" in response to the border shooting.
Air raids continued into Friday evening, with a number of explosions in different parts of Gaza, AFP correspondents said.
The military wing of Hamas, which has fought three wars with Israel since 2008, said three of its fighters were killed in strikes.
Israeli defence minister Avigdor Lieberman warned of a "much tougher" response to any fresh missile fire by Hamas after the army reported "three launches" from the territory, two of which were intercepted.
Israeli media reported prime minister Benjamin Netanyahu received an emergency briefing from the army on the violence.
Last weekend saw the most severe exchange of fire between Israel and Palestinian militants in Gaza since the 2014 war.
Israel hit dozens of sites it said belonged to militants in the Gaza Strip in last Saturday's strikes, killing two Palestinian teenagers.
The same day, around 200 rockets and mortars were fired at Israel from Gaza and four Israelis were wounded when a rocket hit a house in the nearby Israeli city of Sderot.
Since protests broke out on March 30, at least 149 Palestinians have been killed.
Most were shot during demonstrations and clashes along the border, but others were killed in air strikes or by tank fire.
For more than a week, Israel has been hardening its response to kites and incendiary balloons launched from Gaza, which authorities say have set ablaze more than 2,600 hectares (6,400 acres) on Israeli territory.
In recent days, the Israeli army has opened fire at groups launching such devices.
Mr Lieberman has raised the threat of a large-scale operation in the Gaza Strip if Hamas does not stop the kites and balloons being launched.
Israeli television this week broadcast footage of army training manoeuvres for an incursion into the Gaza Strip.
Mr Netanyahu also toured the border region for the first time since the start of the clashes.
Government officials such as Education Minister Naftali Bennett and Internal Security Minister Gilad Erdan have called for systematic attacks on kite launchers.
Israel has also further tightened its blockade of Gaza by restricting use of the only goods crossing, suspending oil and gas deliveries.