Israel’s prime minister Benjamin Netanyahu has returned home from Washington, heading straight into military consultations after a night of heavy fire as Israeli aircraft bombed Gaza targets and the strip’s militants fired rockets into Israel.

Schools in southern Israel were cancelled following the violence that threatened to escalate into a major conflict just two weeks before the Israeli elections.

The fighting subsided by the morning, though the situation remained tense.

The military massed forces on the Gaza border and imposed restrictions on civilian public gatherings after dozens of rockets were fired toward communities in the area, including one that struck a house in the town of Sderot.

Overnight, the Israeli air force pounded militant sites of Gaza’s Hamas rulers and the smaller Islamic Jihad group.

The targets included a multi-storey building in Gaza City that Israel said had served as a Hamas military intelligence headquarters and the office of Hamas leader Ismail Haniyeh.

Gaza’s health ministry said seven Palestinians were wounded in the airstrikes.

Mr Netanyahu, back from Washington, headed directly to military headquarters in Tel Aviv for consultations on the next steps.

He faces the difficult task of delivering a tough blow to Hamas while avoiding protracted fighting that could work against him on election day.

Gaza Israel
An explosion caused by Israeli airstrikes is seen in Gaza City (Adel Hana/AP)

Mr Netanyahu has come under heavy criticism from both allies and opponents for what they say has been an ineffective policy of containing Gaza militants, with calls demanding he deliver a devastating blow to Hamas.

He has conducted indirect ceasefire talks through Egyptian mediators in recent months, and even allowed the delivery of millions of dollars of Qatari aid to Hamas to ease harsh conditions in Gaza.

After a meeting with President Donald Trump and before leaving Washington, Mr Netanyahu indicated the election would not deter him from acting.

“We have responded very, very forcefully.

“Hamas needs to know that we will not hesitate to go in and take all necessary steps, regardless of anything, any date, other than Israel’s security needs,” he said.

The cross-border fighting was triggered by a surprise rocket fired early Monday from Gaza that slammed into a house in central Israel and wounded seven people.

The Israeli military said it was a self-manufactured rocket with a range of 75 miles, making it one of the deepest strikes ever carried out by Hamas.

Trump US Israel
Israeli prime minister Benjamin Netanyahu (Susan Walsh/AP)

The military mobilised two armour and infantry brigades and drafted some reserve forces before striking back at militant sites in Gaza.

Gaza’s Hamas rulers announced later in the day that Egyptian mediators had brokered a cease-fire but the firing continued overnight before calm appeared to return early Tuesday.

The rocket attack prompted Mr Netanyahu to cut short a visit to Washington and return home, setting the stage for perhaps the most serious conflict since a war in 2014.

But with no fatalities reported on either side yet, and the quiet holding for the moment, it still seemed possible to step back from the brink once again.

Two weeks ago, rockets were fired from Gaza toward Israel’s densely populated commercial capital of Tel Aviv, and the Israeli military struck back.

Gaza’s Hamas leaders said the rocket was fired accidentally and the fighting quickly subsided.

Israel and Hamas have fought three wars in the last decade.

Although neither side appears to have an interest in another war, fighting could easily spin out of control.

The 2014 conflict lasted 50 days and ended with over 2,000 Palestinian deaths, including hundreds of civilians, and 73 killed on the Israeli side.

Israel Gaza
A house is damaged after it was hit by a rocket in Sderot, southern Israel (Ariel Schalit/AP)

In Gaza, Hamas is facing perhaps its toughest domestic test since seizing control of the coastal territory from the rival Palestinian Authority 12 years ago.

An Israel-Egyptian blockade, imposed to weaken Hamas, combined with sanctions by the Palestinian Authority and mismanagement by the Hamas government, have all fuelled an economic crisis that has left Gaza with an unemployment rate above 50%.

Hamas has been leading weekly protests along the Israeli border for the past year in hopes of easing the blockade, but the demonstrations, in which some 190 people have been killed by Israeli fire, have done little to improve conditions.

Last week, hundreds of Gazans protested against the dire conditions, a rare expression of public discontent against the authoritarian government.

Hamas responded with a violent crackdown, beating and arresting dozens of demonstrators and drawing rare public criticism.

By limiting its fire to border communities after Monday’s long-range launch, Hamas seems to be trying to keep the conflagration on low intensity. For Israelis living along the border who have suffered from years of rocket attacks that is little comfort.

“The Israeli government can’t, under no circumstances, settle,” said Haim Jellin, a Labour party candidate for parliament and a former head of the bordering Eshkol regional council.

“Firing at Israeli communities that border with Gaza is the same as firing toward Tel Aviv, and it’s impossible we will show restraint at the continuous firing.”