The two rockets fired at Tel Aviv from the Gaza Strip — sparking a retaliatory strike on Hamas targets by Israeli warplanes — were likely launched by mistake during routine maintenance work by militants, the Israeli military said Friday.

It was not immediately clear if the rockets were mistakenly fired by bumbling workers or because of a technical malfunction Thursday night, catching the Israeli army by surprise.

“There is a growing assumption that the Hamas rocket fire towards the Gush Dan region was by mistake,” the Israel Defense Forces said Friday, according to the Jerusalem Post.

IDF spokesman Ronen Manelis told Channel 13 News that “we did not have advance knowledge of this fire today, and in fact it surprised us.”

Militants are believed to have fired the errant M-75 Fajr missiles shortly after 9 p.m. Thursday, sending Israelis in the bustling commercial and coastal cultural capital of Tel Aviv to social media to report the wailing sirens and explosions.

Israel’s Iron Dome missile defense system was activated as a result of the launches, which caused no injuries or property damage. It was believed the Hamas rockets landed in open areas.

Police said they found remains of one rocket in an uninhabited area “in central Israel.”

Just after dawn Friday, six more missiles were fired from Gaza toward Israeli border towns but all but one were intercepted by the Iron Dome system, the military said.

Both Hamas, the Islamist movement that runs Gaza, and its ally Islamic Jihad denied they were behind the rocket fire — but the IDF said they were launched by Hamas.

Israel has long said it holds Hamas responsible for all violence from Gaza, which it has controlled since 2007.

On Friday, Secretary of State Mike Pompeo said the militants who fired on Israel were “armed and financed by their puppet masters in Tehran.”

“We stand by our ally. Israel has the right to protect its citizens,” tweeted Pompeo, who is due to travel soon to the Jewish state.

In response to the attack on Tel Aviv, the first time the city was targeted since a 2014 war between the Jewish state and Gaza militants, Israeli jets hit about 100 Hamas targets in Gaza.

The army said targets included an office building in Gaza City used to plan militant activities, an underground complex that served as Hamas’ main rocket manufacturing site and a center used by the Palestinian fundamentalist organization for drone development.

In Gaza, health officials said four people were wounded in the Israeli strike, including a husband and wife in the southern town of Rafah.

A Hamas official said on condition of anonymity that an agreement to restore calm had been reached after Egypt-led mediation efforts “apparently paid off.”

The flare-up comes three weeks before Israel holds its general election on April 9.

Jason Greenblatt, President Trump’s envoy to the Middle East, condemned Hamas and other Gaza-based terror groups for the escalation.

“Hamas, PIJ and PFLP are all running for the hills (tunnels) denying responsibility for the rockets tonight,” he tweeted, referring to the Palestinian Islamic Jihad and the Popular Front for the Liberation of Palestine.

He also noted that earlier the same day, Hamas violently suppressed demonstrations against the group within the Gaza Strip “with live bullets, beatings and detentions. Hamas causes much suffering in Gaza!”

With Post wires