JERUSALEM – Gaza militants agreed to a cease-fire with Israel to stop spiking violence, a Hamas official said Sunday, after a deadly attack across the Egyptian border on Israeli vehicles set off a three-day round of rapidly escalating Israeli airstrikes and rocket barrages from Gaza.

The sudden flareup also threatened Israel-Egypt relations, after three Egyptian police were killed as the cross-border clash developed Thursday. Egypt complained strongly as thousands demonstrated in Cairo, and Israel apologized.

The senior Hamas official said Sunday afternoon that militant groups in Gaza agreed that the truce would go into effect Sunday evening.

Hamas security personnel would enforce the agreement brokered by Egypt, the official said. He said Egypt told the groups that Israel would agree to halt its airstrikes only if the Palestinians stopped the rocket fire first.

Earlier Sunday, a salvo of rockets from Gaza struck an empty school and sent thousands of Israelis into bomb shelters. Israel responded with airstrikes and diplomats scrambled to limit the violence.

Some of the diplomatic efforts were aimed at limiting the damage from the deaths of the three Egyptian police.

On Sunday morning, an Israeli envoy arrived at Cairo’s international airport and was whisked off in a convoy of four waiting cars, airport officials said. Israel’s government would not comment on the envoy’s identity or the details of his mission. A second unidentified envoy arrived later Sunday, the Egyptian officials said.

Diplomats in Cairo and Jerusalem said the United States, France and Germany were working with the Israelis and Egyptians to end the diplomatic spat. They spoke on condition of anonymity in order to discuss ongoing diplomatic efforts.

Alongside the diplomacy, Israel threatened to intensify its attacks if the rocket barrages continue.

Speaking to Israel Radio, military spokesman Brig. Gen. Yoav Mordechai said Israel “will not hesitate” to widen its military operation if necessary.

Diplomats scrambled to try to prevent the violence — the deadliest since Israel went to war against Gaza militants 2 1/2 years ago — from spiraling out of control.

Large-scale Israeli military operations in Gaza would create new friction with the Muslim world at a time when Palestinian President Mahmoud Abbas is preparing to ask the United Nations to recognize an independent Palestinian state. Pictures of a major Israeli offensive in Gaza could hurt the Jewish state’s efforts to minimize world support for the Palestinian statehood bid.

A spokesman said Abbas’ Palestinian Authority planned to use the renewed violence to bolster its case for statehood at the United Nations next month.

“An independent Palestinian state is the remedy for violence,” Husam Zomlot said. “It would control its borders and prevent such deterioration from happening.”