Neither side retreated from threats to resume the conflict if the deal fell through, and both said they had only reluctantly agreed under international pressure. In a televised news conference, Prime Minister Benjamin Netanyahu of Israel declared that some Israelis still expected “a much harsher military operation, and it is very possible we will be compelled to embark on one.”

But he said that in a telephone conversation with Mr. Obama earlier in the evening, “I agreed with him that it is worth giving the cease-fire a chance.” He added that he had reached an undisclosed agreement with Mr. Obama to “work together against the smuggling of weapons” to Palestinian militants, for which Mr. Netanyahu blamed Iran.

Khaled Meshal, Hamas’s top leader, thanked Iran for its military support in a triumphal news conference in Cairo. “This is a point on the way to a great defeat for Israel,” he said. “Israel failed in all its objectives.”

He suggested that the West had come to Hamas and its Islamist allies in Egypt pleading for peace. “The Americans and the Europeans asked the Egyptians, ‘You have the ear of the resistance,’ ” he said, using the term Hamas prefers to describe itself and other Palestinian militants fighting the Israeli occupation. “Egypt did not sell out the resistance as some people have claimed. Egypt understood the demands of the resistance and the Palestinian people.”

The agreement postponed the resolution of the most contentious issue: Israel’s tight restrictions on the border crossings into Gaza under a seven-year-old embargo imposed to thwart Hamas from arming itself. The one-page “understanding” regarding the cease-fire called for “opening the crossing and facilitating the movement of people and transfer of goods,” but it also said that “procedures of implementation will be dealt with after 24 hours from the start of the cease-fire.”

But however fragile the cease-fire may be, the deal itself may be a turning point for Egypt’s Islamist leaders, in both their relations with the West and their role in the region. Since the ouster of Hosni Mubarak — a reliable ally of Washington and Israel — many in the West have been worried about how Egypt’s leaders might respond to the next confrontation that pits their allies in Hamas against Israel. As a leader of the Muslim Brotherhood’s parliamentary bloc, Mr. Morsi often railed against Israel’s occupation of the Palestinian territories and praised Hamas for rejecting the Western-backed peace process in favor of armed resistance.