JERUSALEM — Israel and Hamas hurtled into their deadliest bout of fighting in nearly five years on Sunday as Palestinian militants launched a barrage of more than 600 rockets and Israel responded with airstrikes on more than 300 targets.

Four Israeli civilians were killed, the first from rocket fire from Gaza since 2014, and 23 Palestinians died. The exchange threatened to push the sides toward a new war and derail efforts to broker a longer-term truce. Mediation over a new cease-fire was underway on Sunday night.

Israeli Prime Minister Benjamin Netanyahu met for more than four hours with his security cabinet. He said he had instructed the military to continue strikes and prepare “for the next stages.”

Earlier Sunday, Netanyahu said he had ordered “massive attacks against terrorist elements in the Gaza Strip.”

Eli Cohen, minister for the economy and a security cabinet member, said the meeting ended with a “clear decision.”

“We are preparing for a campaign against Hamas and Islamic Jihad, and we will extract a price from them they have not experienced yet,” he said.

Israel generally holds Hamas, which controls Gaza, responsible for any rocket fire from the area. But the Israeli military said Islamic Jihad, the second-largest militant faction in the Palestinian enclave, had instigated the violence.

Israel’s Iron Dome missile defense system appeared to be overwhelmed by the barrage, intercepting only 150 of the 510 rockets that crossed into Israeli territory. The Israeli military said about 90 rockets fell short.

Israel said it responded with airstrikes against more than 320 military targets in Gaza. Palestinian militant factions said they were retaliating in an “unprecedented manner” after residential buildings were hit, and they threatened to expand the range of their rockets if the “aggression” continued.

Palestinian health officials said the dead in Gaza included two pregnant women, a 12-year-old boy and two infants. The Israeli military denied it was responsible for the strike that killed one of the pregnant women and a baby, saying a Palestinian rocket misfired.

It was the deadliest round of fighting since the 2014 war between Israel and Hamas, and the Israeli civilian casualties were the first from rocket fire since then. The exchange came amid negotiations between Israel and Hamas over a deal in which Israel would ease restrictions on Gaza in return for calm. 

Hamas accuses Israel of reneging on its commitments so far, including a deal it said they agreed to after the last violent flare-up in March. which caused Netanyahu to cut short a visit to Washington. Hamas said Israel had agreed to continue to permit $30 million in Qatari cash for employment projects and humanitarian aid, expand fishing rights and ease trade restrictions.

In recent months, the cash has not arrived, and Hamas has fallen under increasing pressure ahead of the Muslim holy month of Ramadan, a time of traditional fasting and feasting.

“Hamas believes that Netanyahu has abandoned his commitments, and they believe this is a very important time to put on pressure and get Israel to make good on promises,” said Mkhaimar Abusada, a professor of politics at Gaza’s al-Azhar University.

He pointed to Israel’s independence day celebrations this week and the Eurovision song contest the week after. The popular international singing competition is to be broadcast from Tel Aviv, with Madonna expected to perform.

“Whether the calculation was right or wrong, we’ll see,” Abusada said.

Hamas leader Ismail Haniyeh said a “return to calm” was possible if Israel committed to implementing the “understandings” that had been reached.

Reports in Palestinian media that a midnight cease-fire had been agreed to could not be confirmed.

“The cease-fire is possible, but the occupation has to pay for its obligations,” Islamic Jihad leader Daoud Shihab said.

While Hamas and Islamic Jihad said they hoped to strong-arm Israel into easing restrictions on Gaza, Israel announced it would cease all fuel imports into Gaza through the Kerem Shalom crossing, impacting Gaza’s already patchy power supply.

Schools across southern Israel were closed on Sunday as rockets rained down, and streets on both sides of the border were virtually deserted. Lt. Col. Jonathan Conricus, an Israeli military spokesman, said Israel’s Iron Dome system was dealing with a “diverse” and “fast-paced” threat.

Amos Yadlin, former head of Israeli military intelligence, said Hamas had probably developed a new tactic to bypass the Iron Dome.

“They are using the same kind of rockets they used in the past,” said Yadlin, now head of Israel’s Institute for National Security Studies. “But this time, they are firing them in a salvo of eight, 10 or 12 at the same time.”

Conricus said 35 rockets had struck urban areas. The first Israeli civilian fatality from rocket fire since 2014 came in the early hours Sunday, when a 58-year-old man was killed after a rocket hit his home in Ashkelon.

A 50-year-old Israeli man was killed in a factory in Ashkelon, and a 67-year-old Israeli man succumbed to his injures after an antitank missile hit his car. As night fell, a fourth Israeli, in his early 20s, according to Israeli media, was confirmed killed in the southern city of Ashdod.

In Gaza, Israeli strikes toppled buildings as high as seven stories. Palestinian officials there said one strike Sunday evening hit an apartment, killing a 31-year-old man, a 30-year-old woman and a 4-month-old girl. 

Conricus said Israeli intelligence had confirmed that a Palestinian woman and a 14-month-old baby killed the day before did not die as a result of an Israeli strike, but of Palestinian rocket fire. 

Islamic Jihad said eight of those killed were its militants. Hamas did not confirm fatalities among its fighters. 

Conricus said Israeli targets included weapons storage facilities in the homes of militants, attack tunnels and military headquarters. The Turkish news agency Anadolu said its Gaza office was struck.

The Israeli military said an armored brigade and two infantry brigades had mobilized to the border area and were prepared for “offensive” action. Officials also said they had carried out the first targeted assassination of a Hamas militant in “several years.” 

Conricus said the military worked with the Israeli Security Agency to assassinate Hamed Khudary, 34, who it said was responsible for channeling Iranian money to Hamas and Islamic Jihad.

Right-wing Israeli politicians have repeatedly called on Netanyahu to restart the tactic of targeted assassinations. 

U.S. Secretary of State Mike Pompeo said he hoped the sides would return to the cease-fire that had been in place for weeks and had been “holding significantly.”

“It’s pretty serious,” he told Fox News on Sunday. “The Israelis have every right to defend themselves.” 

Israel previously denied that it had reached a cease-fire deal with Hamas. Representatives of Hamas and Islamic Jihad were locked in negotiations in Cairo on Sunday as Egypt attempted to broker a truce.

Shimrit Meir, an Israeli analyst, linked the escalation to Hamas’s discontent over the delivery of Qatari assistance.

“It’s nearly Ramadan; people are starving,” she said. “We as Israelis think about the Eurovision, but they are preoccupied with demands from the public. They are waiting for the Qatari cash.”

Basem Naim, a senior Hamas official, said there were several reasons for the escalation, one of which was the lack of progress in negotiations on a long-term deal with Israel.

“We’ve talked about long- and short-term solutions, money, the fishing zone, but nothing is happening on the ground,” he said.

He said Hamas had tried to rein in violence at border protests on Friday but was frustrated by Israel’s continued use of live fire against the demonstrators. U.S. and Israeli moves, such as President Trump’s decision to move the U.S. Embassy to Jerusalem and to recognize Israeli sovereignty over the Golan Heights, have further spurred the group to take action, he said.

Hamas has used weekly protests to ramp up pressure on Israel and divert the frustrations of Gaza residents after more than a decade of siege. Two demonstrators were killed by Israeli snipers Friday, before militants carried out a shooting attack at the border. 

Israel responded with a strike that killed two Hamas militants. 

“It has escalated gradually,” Naim said. 

The United Nations said Secretary General António Guterres was following the developments with “deep concern.” Guterres deplored the “risk of yet another dangerous escalation and further loss of life on the eve of the holy month of Ramadan,” condemned the rocket fire in the “strongest terms,” and urged all parties to exercise “maximum restraint,” the United Nations said.

Balousha reported from Gaza. Paul Sonne in Washington contributed to this report.