JERUSALEM — A shaky cease-fire took hold Thursday between Israel and Islamist militants in the Gaza Strip after two days of fighting that killed 34 Palestinians and forced thousands of Israelis to take shelter amid a rain of rockets.

Despite reports of sporadic launches later in the day, both sides began to assess the fallout from the latest clash in the conflict’s cycle of attack and reprisal — a battle in which Hamas, the governing militant faction in Gaza, this time stayed largely on the sidelines.

The near-constant barrage slowed in the morning for nearly the first time since Israeli forces killed an Islamic Jihad commander in a strike on his safe house early Tuesday. In the surge of violence that followed, almost 400 rockets flew from Gaza, most of them exploding in open countryside or shot out of the sky by Israel’s air-defense shield. But several homes and factories inside Israel were struck.

Israel responded with air and tank assaults on dozens of Islamic Jihad targets in Gaza, including rocket launchers, tunnels and the homes of militant leaders. The Palestinians said that of the 34 killed in the attacks, at least six were children, and that 111 people were injured.

In the hours before the cease-fire began, Israel struck the home of a second militant commander, killing him and seven members of his family, according to the Palestinian Ministry of Health. The Israeli military said 25 of those killed over the two days were confirmed militants.

As the crossfire of explosions quieted Thursday, Gazans slowly returned to the streets. Stores opened as municipal trucks and bulldozers began to scrape up the debris in areas hit by Israeli shelling. Schools and universities were closed for a third day.

Many of the Palestinians who ventured out seemed exhausted but also relieved that the conflict did not escalate into what would have been the fourth full-scale war with Israel in 10 years.

“We have turned a bleak page of anxiety and fear and waiting for death, but we have started a page of sadness and crying and loneliness,” said Rose Bakri, who was walking on Nasser Street in Gaza City.

The cease-fire was brokered in Cairo. “Egypt and the U.N. worked hard to prevent the most dangerous escalation in and around Gaza from leading to war,” Nickolay Mladenov, the United Nations’ Middle East peace envoy, tweeted Thursday.

Scenes of rockets streaking across the sky and of Israelis dashing for cover as missile warning sirens wailed filled live Israeli television broadcasts over the past 48 hours.

In the southern town of Sderot, where residents have been subjected to intense bouts of rocket fire regularly for more than a decade, a mattress factory was gutted by a rocket strike, which destroyed the company’s stock and eliminated, at least for now, about 200 jobs.

Business owners told local news outlets that the attacks make it extremely difficult for them to earn a living. Compensation provided by the Israeli government after each round of fighting is not enough, they said.

Israel said it was justified in its initial surprise predawn strike Tuesday because its target, Islamic Jihad commander Baha Abu al-Ata, was behind multiple recent attacks on Israel and was preparing more. Military officials insisted that they focused tightly on assets belonging to Islamic Jihad, hoping not to provoke Hamas into action.

The aim was to “improve the security situation by providing a significant blow” to Islamic Jihad, said Lt. Col. Jonathan Conricus, an Israeli army spokesman. “We wanted to keep Hamas out of the fighting and stabilize the situation in and out of Gaza.”

Hamas itself reportedly had been struggling to tamp down Abu al-Ata’s activities, viewing them as a threat to its tentative detente with Israel and its efforts to improve living conditions in Gaza.

Gaza-based political analyst Hani Habib said it was significant — and shrewd — that Hamas left the violent response to Abu al-Ata’s killing to the smaller militant group.

“Hamas was wiser because it did not enter the front line,” Habib said.

Israeli officials appeared largely pleased with the two-day action, which left one Gaza military faction badly damaged and Hamas in a position to maintain order in the enclave. Eliminating Abu al-Ata, they argued, served both Israel and Hamas.

“He carried out acts of terror every few days depending on his mood,” said retired Maj. Gen. Amos Gilad, the director of the Institute for Policy and Strategy at the Interdisciplinary Center in Herzliya.

Hamas has a tighter grip in Gaza for both good and bad, he said. Abu Al-Ata “challenged even Hamas, but that doesn’t make Hamas moderate,” Gilad said. “They want a monopoly on everything, including governing and carrying out acts of terror.”

Shimrit Meir, a Tel Aviv-based analyst of Palestinian affairs and regular contributor to the daily Yedioth Ahronoth, said the operation was clearly carefully planned.

“I think the main thing was that they managed to separate Hamas and Islamic Jihad. To all those who watch Hamas closely, they were surprised to see them standing on the side and watching what was going on to their fellow organization and yet staying out of it,” Meir said.

Balousha reported from Gaza City.

Read more: