GAZA STRIP - The first ceasefire in seven weeks of war in Gaza is due to come into effect on Thursday morning, officials from both Hamas and Israel have said.

A four-day truce was announced early on Wednesday, after days of feverish speculation and intense negotiations.

But more than 100 Palestinians were reported killed on Wednesday as Israeli forces continued attacking Gaza from land, sea and air before the deal came into force.

Related: Over 100 Palestinians reported killed in Gaza as attack continues despite ceasefire deal

Under the agreement, Hamas will free at least 50 of the more than 240 mostly Israeli hostages they took on 7 October. In turn, Israel will release at least 150 Palestinian prisoners and allow up to 300 trucks of humanitarian aid into Gaza after more than six weeks of bombardment, heavy fighting and a crippling blockade of fuel, food, medicine and other essentials.

There will be a halt to Israeli air sorties over southern Gaza, with air activity over northern Gaza restricted to six hours a day. According to a Hamas statement, Israel has agreed not to arrest anyone in Gaza for the duration of the temporary truce.

Related: Gaza ceasefire deal brings relief but little hope of durable peace

The logistics of arranging the complex exchange of prisoners and hostages while enforcing a pause in fighting could still mean delays. In Israel, the supreme court has to approve the release of some prisoners to be exchanged.

The hostages to be freed are women and children, and the Palestinian prisoners are also women and people aged 18 and younger, both sides have confirmed.

If the first exchanges go well, and Hamas can locate more female hostages or children, there will be further releases on both sides, reports suggest.

The deal, struck after weeks of talks mediated by Qatar, the US and Egypt, comes more than six weeks after the conflict began on 7 October, when Hamas launched attacks from Gaza into southern Israel, killing at least 1,200 people, mostly civilians, and taking more than 240 people hostage.

The Israeli offensive has killed between 13,000 and 14,000 people, thousands of them children, according to Palestinian officials. More are thought to be under rubble. Swaths of northern Gaza have been destroyed in the fighting, and up to a million people displaced.

Though the deal has raised hopes of a more durable cessation of hostilities, Benjamin Netanyahu, the Israeli prime minister, has vowed to “complete the elimination of Hamas and ensure that there will be no new threat to the State of Israel from Gaza.”

“We are at war, and we will continue the war,” Netanyahu said. “We will continue until we achieve all our goals.”

The Israeli government approved the deal only after a sometimes acrimonious marathon overnight debate.

Yoav Gallant, Israel’s defence minister, emphasised that “immediately after we have exhausted this phase”, military operations would “continue in full force”.

Israeli officials may be encouraged by the decision of Hezbollah, the Lebanon-based Islamist militia and political movement, to observe the truce, despite not having been involved in negotiations. Violence has increased along Israel’s northern frontier, with a series of tit-for-tat exchanges of fire.

The Israeli cabinet’s signoff was one of the last hurdles after what one US official described as five “extremely excruciating” weeks of talks.

One stumbling block was getting the consent of Yahya Sinwar, Hamas’s leader in Gaza, whose views have often diverged from those of Hamas leaders outside the territory. This was “late coming”, analysts said. An official of the Islamist group said that “the resistance is committed to the truce as long as the occupation honours it”.

If the initial phase of the deal works, 150 more Palestinian prisoners could be released in a subsequent phase in exchange for 50 more hostages, according to an Israeli government document that named 300 eligible prisoners. For every 10 additional hostages released, there would be an extra day’s “pause” in fighting, the document said.

Israel’s Hostages and Missing Families Forum welcomed the deal. “We are very happy that a partial release is pending … but as of now, we don’t know exactly who will be released when,” the group said.

Related: Families of Gaza hostages wait to see if relatives among those freed

The lack of clarity over exactly who was to be freed caused distress on both sides.

“We don’t know who will get out because Hamas will release the names every evening of those who will get out the next day,” said Gilad Korngold, whose son and daughter-in-law are being held in Gaza along with their two children and other relatives.

Israel’s list of eligible Palestinian prisoners included 33 women and 123 young people, most charged with public order offences or arson. No prisoners convicted of murder will be freed, local media reported, but two serving long sentences for stabbing an Israeli officer are on the list.

Amani Sarahneh, spokesperson for the Palestinian Prisoners’ Club advocacy group, said: “We don’t know who will be freed first, and that’s a problem for us in responding to the families”.

Among the Palestinians who could be released is Shorouq Dwayyat, convicted of attempted murder in a 2015 knife attack. Her mother, Sameera Dwayyat, said she hoped her daughter would come out in a deal” but added that her relief was tempered by “great pain in my heart” over the dead children in Gaza.

A senior US official said three American hostages, including three-year-old Abigail Mor Idan, were among 50 earmarked for release from Thursday.

Even if fully implemented, the current agreement would still leave about 190 hostages in Gaza, of whom about half are thought to be military personnel.

The truce deal was welcomed by countries including Britain, China, France, Germany, Jordan and Egypt, whose president, Abdel Fattah al-Sisi’s office, touted the “success” of the mediation.

Not all the hostages are being held by Hamas, with some in the hands of Palestinian Islamic Jihad, a separate extremist faction, and criminals in Gaza, say Israeli and other officials.

Almost half of the hostages have dual nationality, including from Argentina, Germany, America, France, Thailand, Nepal and Russia. Hospitals in Israel have been prepared to receive those released, Israeli media reported.

Related: Yahya Sinwar: the man who may hold key to release of Gaza hostages

The deal is a significant propaganda coup for Hamas and a personal victory for Sinwar, who spent 23 years in Israeli prisons before being released in an exchange in 2011. He tops Israel’s hitlist and his whereabouts are unknown.

Meeting the terms of the deal will require Hamas to ensure that all 50 hostages reach the borders of Gaza safely, a logistical challenge. The group indicated during negotiations that it did not know the exact location of every hostage because of the varied groups holding them.

Netanyahu will now be under domestic pressure to get the rest of the hostages freed, but faces growing political risks. Several far-right parties that are part of the ruling coalition on Tuesday evening opposed the proposed deal and called for the Israeli offensive in Gaza to be intensified to secure better terms. Their statements prompted protests in Tel Aviv by hostages’ families.

If Israel does resume its offensive, its military are likely to attempt to advance into southern Gaza. It is not clear what would happen to the more than 2 million civilians sheltering there. Senior US officials have suggested they would not support any such offensive without a credible plan to protect that population.

Josep Borrell, the EU’s head of foreign affairs, said the Israeli military had told him they planned to create a “small safe area along the sea in the southern part of Gaza” for the civilian population “in order to carry out the ground operations in the south”.

Israeli military officials have suggested the plan in recent days, prompting deep concern even among staunch allies. “This did not reassure me about the future course of events if we fail to achieve a rapid and durable de-escalation of the military operations,” Borrell wrote.