JERUSALEM — After a lull in the latest round of fighting between Israel and Hamas on Thursday, militants in Gaza fired a rocket toward the southern Israeli city of Beersheba, a major population center about 25 miles away, for the first time since the last war in 2014.
In response, Israeli missiles flattened a five-story building in western Gaza City, injuring 18 people, according to Gaza health officials. Israel said the building was used by Hamas’s security forces for military purposes. The Palestinians said it was a center for the arts, housing a theater and a library, as well as an office serving Egyptians residing in Gaza.
The sharp blows left many wondering if these were the final shots ushering in a new, if fragile, cease-fire, or the opening shots of the next war.
Officials in Gaza said late Thursday that a cease-fire brokered by Egypt and the United Nations envoy to the region, Nickolay Mladenov, would begin at midnight. They described it as a limited understanding of “calm for calm.” But it was not likely to be any more stable than the cease-fires that came before.
Analysts on both sides said Israel and Hamas were trying to improve their negotiating positions for a longer lasting truce by letting their guns talk.
“These are the final minutes or hours for Hamas and Israel to reach agreement on understandings to calm the situation,” said Talal Okal, a Palestinian writer and political analyst, referring to the intensive efforts of Egypt and Mr. Mladenov in recent weeks to broker a firmer, long-term cease-fire agreement between the sides.
“Each wants to improve their conditions for this understanding,” Mr. Okal said by telephone from Gaza City. “So Israel’s message is that nobody can threaten it. It’s a psychological message. The Palestinian message is to tell the Israelis that we are ready to respond to any Israeli aggression in Gaza.”
Experts on both sides said that neither Israel nor Hamas had an interest in causing a major conflagration right now.
“As we approach a potential agreement it is very important for Hamas to deliver the message that they are not going there because they are weak, or deterred or cannot find a better way to handle the situation,” said Yossi Kuperwasser, a former director general of Israel’s Ministry of Strategic Affairs.
“In spite of the fact that both sides have no real interest in escalation, both sides act in a way that may lead to escalation,” Mr. Kuperwasser said.
This week’s flare-up began, as many had warned, with a misunderstanding over Hamas fire on Tuesday. The Israeli military said shots had been fired from a Hamas post toward its soldiers across the border fence. The military fired a tank shell at the post, killing two Hamas militants.
But Hamas said its snipers had fired as part of a military exercise and were not aiming at Israeli forces. The assertion was later confirmed by the Israeli military.
Hamas vowed revenge and sharply escalated the situation on Wednesday, barraging Israeli territory with rocket and mortar fire. That prompted waves of Israeli airstrikes against what Israel described as military targets in Gaza.
By late Thursday, Gaza militants had fired about 200 rockets and mortar shells into southern Israel, injuring several civilians, seven of whom were hospitalized. The Israeli military said it had responded with strikes against more than 150 military targets in Gaza.
Hamas broadcast messages during the day saying that it wanted to restore calm. At lunchtime, the Hamas-led joint militant operation in Gaza sent a short text message to reporters saying that the latest round of fighting had ended. It then distanced itself from the rocket fire against Beersheba, suggesting it was launched by a rogue group. The rocket fell on the outskirts of the city in open ground.
Brig. Gen. Ronen Manelis, the Israeli military’s chief spokesman, said on Israeli television later Thursday that the bombing of the high-rise building in the center of Gaza, in broad daylight, was “a message to Hamas that as long as their choice of terror continues, so the I.D.F.’s responses will increase and become more powerful,” referring to the Israel Defense Forces.
“We are determined to bring back quiet,” he said, adding that the military’s attacks “will get more powerful until quiet returns.”
Hazem Qassim, a Hamas spokesman, described the attack on the high-rise as “barbaric behavior, which belongs to backward eras that fought culture with fire and gunpowder.”
Not part of any strategic calculation were the dead and wounded civilians.
In Deir el-Balah in the central Gaza Strip, people on Thursday gathered tiny body parts from the floor of a one-story rented home where a pregnant woman, Inas Khammash, was killed overnight along with her 18-month-old daughter, Bayan, apparently from an Israeli missile strike. There was a gaping hole in the roof and blood splattered on the walls.
“They were civilians inside their house, dreaming of a new baby who was supposed to be born in the coming few days,” said Kamal Abu Khammash, 33, the woman’s brother-in-law.
Lt. Col. Jonathan Conricus, another Israeli military spokesman, confirmed that airstrikes had been carried out in the vicinity of Deir el-Balah. He added: “We target only military targets. Of course, as always, we do the utmost to minimize collateral damage.” Civilian casualties, he said, were “not the desired outcome.”
On the Israeli side of the border a woman was seriously injured by rocket or mortar fire early Thursday. She was identified in the Israeli news media only as a foreign worker from Thailand.
In the areas of southern Israel near the boundary with Gaza, traumatized families spent the night in fortified safe rooms, and outdoor activities planned for the school vacation were canceled.
Yoav Galant, Israel’s minister of construction and housing, told reporters that if it was necessary to defend its citizens, Israel would “eventually go after each one of the Hamas leaders” but that once the fire stopped, Israel would also be “ready for peace.”
Iyad Abuheweila contributed reporting from Deir el-Balah, Gaza Strip; and Ibrahim El-Mughraby from Gaza City.