The Israeli military carried out its largest airstrike campaign in Gaza since the 2014 war as Hamas militants fired dozens of rockets into Israel throughout the day.

The escalation in the conflict threatened to trigger an all-out war after weeks of growing tensions along the volatile border.

Two Palestinian teenagers were killed in an airstrike in Gaza City, while three Israelis were wounded from a rocket that landed on a residential home.

Palestinians Israel
A Palestinian policeman guards next to a destroyed building following an Israeli airstrike in Gaza City (Khalil Hamra/AP)

Israel said it was focused on hitting militant targets and was warning Gaza civilians to keep their distance from certain sites.

But even before the report of casualties, the intense tit-for-tat airstrikes and rocket barrages still marked a significant flare-up after a long period of a generally low-level, simmering conflict.

“The Israeli army delivered its most painful strike against Hamas since the 2014 war and we will increase the strength of our attacks as much as necessary,” Prime Minister Benjamin Netanyahu said.

Late on Saturday, Hamas and Islamic Jihad militants in Gaza announced that they had agreed to a cease-fire brokered by Egypt, but sirens warning of incoming rockets still wailed in southern Israel early on Sunday and it was unclear if the cease-fire was holding.

Lieutenant Colonel Jonathan Conricus said the latest Israeli sortie, the third of the day, struck some 40 Hamas targets including tunnels, logistical centres and a Hamas battalion headquarters.

He said the escalation was the result of the sustained Hamas rocket attacks, its fomenting of violence along the border and its campaign of launching incendiary kites and balloons that have devastated Israeli farmlands and nature reserves.

Palestinians Israel
Teargas canisters fired by Israeli troops fall over Palestinians during a protest at the Gaza Strip’s border with Israel (Khalil Hamra/AP)

“Our message to Hamas is that we can and will enhance the intensity of our effort if needed,” he said. “What Hamas is doing is pushing them ever closer to the edge of the abyss… Hamas will have to understand that there is a price to be paid.”

Later, witnesses reported that Israeli warplanes dropped four bombs on an unfinished building near a Hamas police and security compound in Gaza City, reducing the old structure to rubble.

The four-storey building is adjacent to a public park, and Gaza’s Health ministry said two teenagers were killed in the strike and ten others injured.

Palestinians Israel
Medics evacuate a wounded Palestinian man following an Israeli airstrike (Khalil Hamra/AP)

Striking in the heart of Gaza City is typically only seen during full-blown conflicts like the 2014 war and could signal that a further escalation may be in store.

The Israeli military had no immediate reaction to that strike but said it had targeted a separate high-rise building in the northern Gaza Strip that was used as a Hamas urban warfare training facility.

On Friday, thousands of Palestinians gathered near the Gaza border for their near-weekly protest. A 15-year-old Palestinian who tried to climb over the fence into Israel was shot dead. Later the military said an Israeli officer was moderately wounded by a grenade thrown at him.

Gaza’s health ministry said Saturday that a 20-year-old struck by gunfire Friday during the protests in the southern Gaza Strip had also died of his wounds.

The Islamic militant group Hamas that rules Gaza has led border protests aimed in part at drawing attention to the Israeli-Egyptian blockade imposed after Hamas took control of Gaza in 2007. The demonstrations have been fueled in large part by pervasive despair caused by the blockade, which has caused widespread economic hardship.

Israel has been warning Hamas in recent weeks that while it has no interest in engaging in the kind of conflict that led to the sides fighting three wars over the past decade, it will not tolerate Gaza militants’ continued efforts to breach the border and its campaign to devastate Israeli border communities with incendiary attacks.

With Israel focused on rising tension along its northern border in its efforts to prevent Iran from establishing a permanent military foothold in post-civil war Syria, it has been wary of escalating hostilities in Gaza.

But Mr Netanyahu has also come under pressure to act from southern Israeli communities, who have once again found themselves under rocket fire from Gaza in addition to contending with the daily field fires.