Hamas and other Palestinian militant groups have accepted an Egyptian-mediated agreement to halt two days of intense fighting with Israel sparked by a botched Israeli special forces raid miles inside Gaza.

The sudden announcement late on Tuesday brought a lull to the outbreak of violence in which both sides launched scores of bombings and reprisal attacks. Israeli civilians hid overnight in shelters from relentless rocket barrages and Palestinians cowered in basements from thundering airstrikes.

Hamas and other smaller militant groups released a statement saying they had accepted the deal brokered by the UN and Egypt.

There was no comment from Israel, but after nightfall, the rocket attacks and Israeli airstrikes had stopped.

Late on Tuesday a UN security council meeting ended without resolution, according to Kuwaiti ambassador Mansour Al-Otaibi.

Israel’s military said about 400 rockets and mortars had been fired from Gaza since Monday afternoon, possibly the highest concentration launched in such a period from the enclave, and its warplanes had carried out more than 100 bombings.

Play Video 0:30 Rockets and interceptors seen in skies above Israeli city of Ashkelon - video

Medics in Gaza said five people had been killed, two of whom were militants. In the Israeli coastal city of Ashkelon, a 40-year-old civilian was killed when a rocket hit a building. It was later revealed that the man was a Palestinian from the occupied West Bank living in Israel. Twenty Israelis have been wounded in the latest bloodshed.

Botched Israeli raid in Gaza sparks violent exchanges Read more

Israel and Hamas have traded tit-for-tat attacks regularly during the past few months, often when Hamas launches rockets in response to Israeli army fire on weekly protests at the frontier – where Palestinians have been calling for an end to the blockade – or on Hamas positions afterwards.

This latest violence, the most intense to date, erupted following Sunday’s Israeli raid. After being exposed at a militant checkpoint, the covert team killed a Hamas commander and fled in a helicopter, witnesses said. Seven Hamas fighters and an Israeli lieutenant colonel were killed in the chaos. Within hours, militants had launched rockets in response.

The extent of the attacks has been ratcheted up. Israel has previously focused on Hamas military positions in open areas but, by Tuesday, residents said three large residential buildings inside densely populated neighbourhoods of Gaza City were now rubble.

Jets bombed Hamas’s main internal security compound in Gaza but the Israel Defence Forces (IDF) said it had blown up sites used for civilian purposes, such as a Hamas-run television building and a structure it said was used for military purposes but also housed a kindergarten.

Play Video 0:12 Moment rocket hits Hamas-run television building in Gaza strip - video

Residents in Gaza reported that Israel had launched low-yield munition warning strikes, what locals call “roof knocks”, on targets before bombing them. This gives civilians several minutes to clear the structure before it is destroyed and may account for the relatively low fatality count.

Shahira al-Rayes, 39, was asleep at home with her husband and two children in Gaza City when she was awakened by her neighbours, crying out that they had heard a “knock” on the building next door.

“When the building was bombed, we felt death. My children and I screamed and screamed,” she said by phone. “After we realised that the shelling was over, I went up to my apartment, trying hard to calm my children and get them back to sleep. I could not sleep until morning.”

In Ashkelon, north of Gaza, Revital Steinberg, a school counsellor, said she had slept in the living room with her daughters, eight and 11, to be closer to their fortified safe room.

“We pretended to camp in the living room. It was like a game,” she said. “The night was terrible. My 11-year-old was really worried about her classmates, messaging them on WhatsApp to try and calm and relax them. It’s not something you can get used to.”

Hamas warned it would begin firing more long-range missiles towards the distant cities of Ashdod and Be’er Sheva if Israel continued its sorties.

“What has been happening so far is the traditional retaliation our enemy must have expected. In the next few hours, what our enemy can’t expect will follow,” the group said.

Hamas and other smaller militant factions in Gaza have stockpiled about 20,000 mortars and rockets, according to the IDF. “Unfortunately, they are not anywhere near the end of their capabilities,” said spokesman Lt Col Jonathan Conricus.

The country’s Iron Dome missile defence system was able to intercept about 100 rockets but appeared to have been overwhelmed by the intensity of the launches. Israel sent additional forces to the frontier on Tuesday as international mediators appealed for restraint.

“The escalation in the past 24 hours is extremely dangerous and reckless,” said Nickolay Mladenov, the UN envoy for Israeli-Palestinian peace. “Rockets must stop, restraint must be shown by all.”

The Israeli prime minister, Benjamin Netanyahu, has been under intense pressure over the past few weeks from some in his own government calling for a more aggressive policy against Gaza.