CAIRO — Israel and Hamas agreed to extend a temporary cease-fire for five days, Egyptian and Palestinian officials announced Wednesday, potentially averting renewed violence and permitting the sides to continue to negotiate a substantive deal to end the war in Gaza.
Yet even as the extension was announced just minutes before a previous truce was set to expire at midnight, violence spiked, with Palestinian militants firing five rockets at Israel and Israel targeting sites across the Gaza Strip in response. It was not clear if the fighting was isolated or whether it might shatter the truce.
Egypt’s foreign ministry and the head of the Palestinian negotiating team announced the extension, which began at midnight local time. A spokesman for Israel’s prime minister had no immediate comment.
The cease-fire extension is meant to grant both sides additional time to negotiate a longer-term truce and a roadmap for the coastal territory.
‘‘We have agreed on a cease-fire for five days,’’ said Azzam al-Ahmad, the head of the Palestinian delegation to the Cairo talks. He noted that there had been ‘‘significant progress’’ but that disagreements remained over the wording regarding security arrangements, reconstruction efforts for the Gaza Strip, and the permissible fishing area.
The lull in violence had been a welcome reprieve for Israelis and Palestinians living in Gaza. During the temporary cease-fire, Israel halted military operations in the war-battered coastal territory and Gaza militants stopped firing rockets, aside from the ones late Wednesday.
The two sides were considering an Egyptian proposal that partially addresses their demands, but deep differences have kept the deal in doubt.
Hamas is seeking an end to a crippling blockade imposed by Israel and Egypt in 2007. The blockade has greatly limited the movement of Palestinians in and out of the territory of 1.8 million people. It has also restricted the flow of goods into Gaza and blocked virtually all exports.
Israel says the closure is necessary to prevent arms smuggling, and officials are reluctant to make any concessions that would allow Hamas to declare victory.
Israel wants Hamas to disarm, or at least be prevented from re-arming. Hamas has recovered from previous rounds of violence with Israel, including a major three-week ground operation in January 2009 and another weeklong air offensive in 2012. It now controls an arsenal of thousands of rockets, some powerful, with long ranges. Gaza militants fired more than 3,000 rockets toward Israel during the war.
Neither side is likely to see all of its demands met, but the Egyptian proposal tabled Tuesday offered some solutions. A member of the Palestinian delegation at the Cairo talks said the proposal calls for easing parts of the Israeli blockade of Gaza, bringing some relief to the territory.
The proposal leaves the key areas of disagreement, including Hamas’ demand for a full lifting of the blockade and Israeli calls for Hamas to disarm, to later negotiations.
The Palestinian negotiator said he had some reservations about the proposal and would try to improve it.
‘‘We would like to see more cross-border freedom, and also to have the question of a Gaza seaport and airport discussed,’’ he said.
The Palestinian official spoke on condition of anonymity because he was not authorized to discuss negotiations with journalists.
As the talks continued, Hamas indicated it was sticking to its demands.
In recorded remarks broadcast on Hamas radio Wednesday, Ismail Haniyeh, the top Hamas leader in Gaza, said that ‘‘achieving a permanent truce can come only through lifting the blockade on Gaza.’’
Israel, meanwhile, signaled it was ready to respond to renewed fire from Gaza following the end of the cease-fire.
‘‘We will continue to defend, continue to operate. We will be ready for any effort, any way, at any time,’’ Israel’s chief of staff, Lieutenant General Benny Gantz, told reporters.
The war began on July 8 with Israel’s air campaign against Gaza’s Hamas rulers, whom Israel blamed for the kidnapping and murder in June of three Israeli teenagers in the West Bank. Nine days later, Israel sent in ground troops to destroy Hamas’ underground cross-border tunnels constructed for attacks inside Israel.
The fighting has so far killed more than 1,900 Palestinians, the majority of them civilians, Palestinian and UN officials say. On the Israeli side, 67 people have died, all but three of them soldiers.