JERUSALEM -- The Israeli army on Tuesday said it was bolstering its forces along the Gaza frontier, even as a fragile truce with the territory's Hamas rulers appeared to hold following an overnight exchange of heavy fire.

Israel's military chief, Lt. Gen. Aviv Kohavi, ordered the troop buildup after consultations with security officials and Prime Minister Benjamin Netanyahu, who had rushed back to Israel from a trip to Washington to deal with the crisis. Late Tuesday, a rocket fired from Gaza set off air-raid sirens in southern Israel, shattering a day-long lull and threatening the tenuous cease-fire announced by Hamas.

Following a meeting with President Donald Trump, Netanyahu was forced to cancel a planned address to the AIPAC pro-Israel lobbying group and return to Israel. Addressing the group by satellite, he said that over the past 24 hours Israel had pounded militant sites in Gaza on a scale not seen since a 2014 war with Hamas.

"I can tell you, we are prepared to do a lot more," he said. "We will do what is necessary to defend our people and to defend our state."

The cross-border fighting was triggered by a rocket fired early Monday from Gaza that slammed into a house in central Israel and wounded seven people. The outbreak of violence comes just two weeks before Israeli elections and is likely to be a key factor in the final stretch of the campaign.

Overnight, the Israeli air force pounded militant sites of Gaza's Hamas rulers and the smaller Islamic Jihad group. The targets included a multistory 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.

Gaza militants responded by firing dozens of rockets into southern Israel, forcing residents to spend the night in shelters and cancelling school across the region.

The fighting subsided by Tuesday morning, but the situation remained tense, with Israeli troops massed along the Gaza frontier and more forces heading to the area.

Senior Hamas official Ismail Radwan told reporters Tuesday that the militant group accepted a cease-fire plan with Israel, saying "we are committed to it" as long as Israel is. There was no immediate comment from Israel.

Netanyahu faced the difficult task of delivering a tough blow to Hamas while avoiding protracted fighting that could work against him on election day. He has come under heavy criticism from both allies and opponents for what they say has been a failure to contain Gaza militants.

He has conducted indirect cease-fire 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 the territory, which has been under an Israeli-Egyptian blockade since Hamas seized power in 2007.

Netanyahu has indicated the election would not deter him from acting.

"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 after meeting Trump.

Two weeks ago, rockets were fired from Gaza toward Israel's densely populated commercial capital of Tel Aviv, and the Israeli military struck back hard, seemingly headed toward all-out-conflict. But Gaza's Hamas leaders said the rocket fire was accidental 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 one, fighting could easily spin out of control.

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

The blockade, combined with sanctions by the Palestinian Authority and mismanagement by the Hamas government, have fueled an economic crisis that has left Gaza with an unemployment rate above 50 per cent.

Hamas has been leading weekly protests along the Israeli perimeter fence 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 had little effect.

Last week, hundreds of Gazans trained their ire on Hamas instead as they protested the dire conditions. 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 seemed to be trying to avoid a wider conflict. 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 Labor 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."