Hamas and Israel have agreed five more days' truce to allow further talks after a tense final countdown to the end of the current 72-hour ceasefire on Wednesday night.

The current truce, which is the eighth bid to end the five-week long war, had been due to expire at midnight, and rocket fire on Israel two hours before its end prompted fears of fresh violence.

There was confusion immediately after the extension of the ceasefire was supposed to come into effect as well, with a series of rockets targeting southern Israel and Israeli military launching air strikes in Gaza in retaliation.

Hamas, the Islamist organisation in power in Gaza, had earlier denied they had launched rockets.

There were no immediate reports of casualties on either side.

Gamal Shobky, the Palestinian ambassador in Cairo, told the Guardian shortly before midnight there would be a five-day ceasefire to give more opportunity for negotiation. "We are very close but there are still some things to resolve."

The news will be welcomed in Gaza, battered by a month-long conflict which inflicted massive damage on infrastructure and housing, as well as killing nearly 2,000 people, mostly civilians. Sixty-four Israeli soldiers died, and three civilians in Israel were killed by rocket fire.

The two sides, talking through Egyptian mediators, appeared to have made progress during the three days of talks, although significant gaps remain between their positions, Palestinian officials in Gaza and Cairo said earlier in the day.

Since the truce came into effect on Sunday, Israel has halted military operations in Gaza and groups based there including Hamas and several smaller Islamist organisations have stopped firing rockets.

The most recent ceasefire was meant to give the two sides time to negotiate a more sustainable halt in hostilities with talks over a possible longer-term peace plan for the territory being postponed for later discussions.

Continued violence would hinder humanitarian aid reaching Gaza and restrict food supply. Sanitation systems, electricity networks and roads have all been badly damaged in the war.

Azzam al-Ahmad, the head of the Palestinian negotiation team in Cairo, blamed Israel for the failure to reach a permanent agreement.

"Because the Israeli delegation hasn't been in Cairo for the whole 72 hours, even though we've been here, an agreement hasn't been reached," he said.

"We had two options: not to reach an agreement, or to extend the ceasefire. And in the final minutes we decided to extend the ceasefire by five days until Monday."

The two sides were closer than ever, particularly on allowing more goods into Gaza, and on the rights of Gazan fishermen to fish in the Mediterranean, Ahmad said, but there were still points of difference, relating to "security" issues – a probable reference to Israel's demand that Hamas disarm – and the building of a seaport and airport in Gaza.

Gaza has been under an Israeli blockade since 2006 which has sent unemployment and poverty soaring.

Easing, or entirely lifting, the blockade is a main aim for the Palestinians, and especially Hamas.

Ahmad said the Palestinian delegation would now travel to the West Bank to consult with the Palestinian president, Mahmoud Abbas, after 10 days in Cairo. The Israeli team has flown between Cairo and Tel Aviv every day.

During the evening, a Hamas-run television channel in Gaza quoted Ismail Haniyeh, a senior political official in Hamas, pledging support for the delegation in Cairo.

"The threats of the enemy leaders only increase with our people's demands and the principal demand is the lifting of the blockade," Haniyeh said.

The channel also broadcast images of Hamas fighters preparing rockets, which it said were still being made in Gaza.

The seaport for Gaza, agreed in principle more than 20 years ago, has become a leading issue.

If controlled by the Palestinians, it could transform the lives of Gaza's 1.8 million people who have been unable to trade and travel freely since Israel and Egypt imposed tight border restrictions in response to a Hamas takeover of the territory in 2007.

But Israel is concerned a port would allow militant groups in Gaza to rearm.

Hamas has recovered from previous rounds of violence with Israel, including a major three-week ground operation in January 2009 and another week-long air offensive in 2012. It now controls an arsenal of thousands of rockets, some with long ranges and powerful. More than 3,000 rockets have been fired toward Israel during the war.

Currently only about 13,000 Gaza residents with special clearance, such as patients and traders, can leave the territory each month through land crossings into Israel and Egypt. Virtually all exports from Gaza are banned.

It appears likely that Egypt will agree to ease restrictions on its border with Gaza if security forces from the Palestinian Authority take control of crossings.

Both sides in the talks are under pressure to conclude a deal. Despite the rhetoric threatening renewed conflict, options for both Israel and Hamas are limited. Hamas is isolated diplomatically and weakened financially. Israel's anti-missile defence systems have proved effective and Hamas's popularity in Gaza prompted by the war could ebb quickly.

In Israel, many were surprised by the casualties sustained by troops who entered Gaza to seek and destroy cross-border tunnels. A new military operation involving a more ambitious deployment of ground forces into densely populated urban areas would be extremely costly for troops and civilians and would be likely to provoke global outrage.

Binyamin Netanyahu, the Israeli prime minister, spoke with the US president, Barack Obama, during the afternoon, Israeli media reported.

Earlier on Wednesday, four police bomb disposal experts, an Italian reporter and a freelance Palestinian translator were killed when ordnance exploded in the northern town of Beit Lahiya.

Simone Camilli, a 35-year-old video journalist working for the Associated Press news agency and Ali Shehda Abu Afash, 36, died when an unexploded 500kg bomb believed to have been dropped in an Israeli air strike exploded at a collection dump for munitions.

"You could hear the explosion five miles away," said Maher Halevi, chief of police at the Beit Lahiya station where the team were based.

The war began on 8 July after a surge of rockets launched by Hamas on Israel. Israel blamed Hamas for the kidnapping and murder in June of three Israeli teenagers in the West Bank. Israel later sent in ground troops to destroy Hamas' underground cross-border tunnels.

The Israeli military was reported to have called up additional reserve soldiers and reinforced troops along the border with Gaza on Wednesday afternoon.

A spokesman told the Guardian that a number of reserves that had been on "rest and recuperation" had been called back up for active duty, but he would not reveal their numbers.

A Palestinian Authority official speaking to mourners gathered at a funeral tent of a man killed by Israeli troops near Nablus in the occupied West Bank earlier this week said that the Palestinian delegation had been surprised by Egypt's hard line.

Hamas officials in Gaza were also critical of the Egyptians. The organisation, an offshoot of the Muslim Brotherhood, is seen by Cairo as a security threat.

Jonathan Spyer, senior research fellow at the Global Research in International Affairs Centre in Herzliya, said that, for Israel, a deal which mirrors the Egypt ceasefire agreement tabled early in the conflict would be acceptable to the Israeli public. That deal was rejected by Hamas, which claimed it had never been shown it.

"Unless there were any major concessions to Hamas, the Israeli public will be happy to return to the stated goal of this operation – a return to peace and quiet," he said, adding that any deal that mirrored the 2012 ceasefire agreement would also be likely to play well in Israel.

The public, he added, would even be likely to tolerate minor concessions in Gaza, such as an extension of its currently heavily restricted fishing zone or an opening of the border in Rafah with a checkpoint controlled by the Palestinian Authority, as was the case at Israel's Erez crossing with Gaza until the outbreak of the latest conflict.

At the same time, Spyer said it was likely that Israel would be in the same situation six months to two years from now, given that its goal of demilitarisation in Gaza – or of the Palestinian Authority taking control of the strip – was unlikely to be achieved.

"I think Hamas will remain in power in Gaza. I can't see that changing," he said.

Israel's hardline foreign minister, Avigdor Lieberman, said that Israel must defeat Hamas even at the cost of another conflagration.

"Israel cannot afford a war of attrition," Lieberman said in a meeting with district heads in Bat Hadar. "If the current ceasefire is heading towards collapse," Israel must "take the initiative, even if it means a significant escalation."