Cross-border fighting between Israel and Gaza’s ruling Hamas group appears to be winding down amid reports of a truce and Israeli media suggestions that a misfire was responsible for the rocket attack on Tel Aviv that triggered the exchange.

Two rockets struck late on Thursday, taking Israel’s military by surprise, and overnight Israeli warplanes hit 100 Hamas targets in Gaza.

The army said targets included an office complex in Gaza City used to plan and command Hamas militant activities, an underground complex that served as Hamas’s main rocket-manufacturing site and a centre used for Hamas drone development.

In Gaza, health officials reported that four people were wounded, including a husband and wife in the southern town of Rafah. The office building struck by Israel had been used by Hamas’s office of prisoner affairs.

An explosion caused by Israeli air strikes on Gaza City
An explosion caused by Israeli air strikes on Gaza City (Adel Hana/AP)

On Friday, Israeli media quoted defence officials as saying a preliminary investigation indicated the rockets were fired by mistake. It was not immediately clear if it was a technical malfunction or human error.

The Haaretz daily quoted the officials as saying the rockets were fired during maintenance work.

Also on Friday, a Hamas official said an agreement to restore calm had been reached. He said Egypt led meditation efforts “that have apparently paid off”.

The sudden outbreak of violence came at a sensitive time for both sides.

Israeli prime minister Benjamin Netanyahu is in the middle of a tight re-election battle. A tough response would draw international criticism and domestic accusations that he is acting out of political motivations ahead of the April 9 vote, but a restrained response would draw criticism from hardline rivals.

The wreckage of a Hamas military site
The wreckage of a Hamas military site (Adel Hana/AP)

Hamas is coping with its own domestic troubles. Israel and Egypt have maintained a crippling blockade on Gaza since Hamas took over the territory in 2007. The blockade, along with sanctions by the rival Palestinian Authority and Hamas’s own mismanagement have fuelled an economic crisis that has driven unemployment over 50%.

Shortly before the rocket attack, Hamas police violently broke up a rare protest by demonstrators angry about dire living conditions in Gaza.

The crackdown triggered heavy criticism on social media. The organisers of a weekly protest along the Israeli border cancelled the demonstration after the escalation.

The fighting came as Egyptian mediators were trying to extend a ceasefire between the bitter enemies, which last fought a war in 2014. The Egyptians left Gaza late on Thursday.

Hamas, which typically claims responsibility for its military actions, denied involvement in the rocket attack on Tel Aviv and even said it had undermined its interests. Israel’s military said earlier that it held Hamas responsible for all attacks coming from Gaza.

The late-night attack on Tel Aviv, Israel’s densely populated commercial and cultural capital, marked the first time the city had been hit since a 2014 war between Israel and Gaza militants.

Following the first Israeli air strikes, several additional rockets were launched into Israel. The military said several were intercepted by its air defence systems, and there were no reports of injuries.