Hamas has released 24 hostages who had been held captive in the Gaza Strip for weeks, and Israel freed 39 Palestinians from prison in the first stage of a swap under a four-day ceasefire deal.

The freed hostages included 13 Israelis, 10 people from Thailand and one from the Philippines, according to Qatar.

The agreement opened the way for sorely needed aid to flow into Gaza for beleaguered residents. It was also a moment of hope for families in Israel and elsewhere worried about loved ones taken captive during the October 7 Hamas attack that triggered the war.

The truce started on Friday morning, bringing Gaza’s 2.3 million Palestinians quiet for the first time after seven weeks of relentless Israeli bombardment, which has killed thousands, driven three-quarters of the population from their homes and flattened vast stretches of residential areas.

Rocket fire from Gaza militants into Israel went silent as well.

The freed Israeli hostages included eight women — six in their 70s and 80s — and three children.

Their release was followed in the evening by the freeing of 24 Palestinian women, including some convicted of attempted murder for attacks on Israeli forces, and 15 teenagers jailed for offences like throwing stones.

But joy at the deal has been tempered, among Israelis by the fact that not all hostages will be freed and among Palestinians by the briefness of the pause. The short truce will leave Gaza mired in humanitarian crisis and under the threat that fighting could soon resume.

Israel Palestinians
Doron Katz and her daughters, Aviv and Raz Asher, were three of the hostages released on Friday (Hostages and Missing Persons Families Forum/AP)

Israel says the ceasefire could be extended if more hostages are released, but has vowed to resume its massive offensive once the truce ends.

That has clouded hopes that the deal could eventually help wind down the conflict, which has fuelled a surge of violence in the occupied West Bank and stirred fears of a wider conflagration across the Middle East.

After nightfall on Friday, a line of ambulances emerged from Gaza through the Rafah crossing into Egypt, carrying the freed hostages, according to live footage on Egypt’s state-run Al-Qahera TV.

Israel’s Channel 13 showed an older woman exiting an ambulance alongside a young girl, then walking slowly into a building. An Egyptian medical team held another older woman’s arms as she walked.

At a plaza dubbed Hostages Square in Tel Aviv, a crowd of Israelis cheered as news of the release was announced. The Israeli military later confirmed that the hostages had returned to Israel and were undergoing medical checks before being moved to hospitals to be reunited with their families.

Israel Palestinians
Channa Peri was held captive in Gaza for weeks (Hostages and Missing Persons Families Forum/AP)

The Foreign Ministry of Qatar, which played a key role mediating with Hamas in the negotiations over the pause, said 13 Israelis, 10 Thais and one Filipino had been freed, but the Thai prime minister said earlier that 12 Thai nationals were freed.

The plight of around 240 people taken captive during Hamas’s attack has been wrenching in Israel, raising anger among some families that the government of Prime Minister Benjamin Netanyahu was not doing enough to bring them home.

Under the deal, at least 50 are to be released, though it is not clear if the Thai and Filipino captives will be included in that count.

Israel is to free 150 Palestinian prisoners, and said the four-day truce can be extended an extra day for every additional 10 hostages freed.

In the West Bank, thousands gathered near the Israeli military’s Ofer Prison, awaiting the release of Palestinian prisoners. Police fired tear gas to disperse the crowd.

Israel Palestinians
An Israeli prison transport vehicle carries Palestinian prisoners released by the Israeli authorities from Ofer military prison (Mahmoud Illean/AP)

According to the Palestinian Prisoners’ Club, an advocacy group, Israel is holding 7,200 Palestinians, including about 2,000 arrested since the start of the war.

Israel holds many for months without charge in administrative detention. Most who are tried are put before military courts that almost never acquit defendants and often do not follow due process, human rights groups say.

Palestinians say a longer ceasefire is needed to recover from the humanitarian catastrophe in Gaza, but Friday’s halt in fighting brought the uprooted population a moment to catch their breath after weeks of fleeing bombardment across the tiny coastal enclave and trying to find increasingly scarce food, water and other basic supplies.

After the truce began on Friday morning, an increased flow of aid began. Four trucks of fuel and four trucks of cooking gas entered from Egypt, as well as 200 trucks of relief supplies, Israel said.

Since the war began, Israel has barred all imports into Gaza except for a trickle of supplies from Egypt.

Israel Palestinians
Daniel Aloni and her daughter Emilia were released on Friday (Hostages and Missing Persons Families Forum/AP)

Its ban on fuel, which it said could be diverted to Hamas, caused a territory-wide blackout. Hospitals, water systems, bakeries and shelters have struggled to keep generators running. Amid food shortages, UN officials had warned in recent weeks of potential starvation.

During the truce, Israel agreed to allow the delivery of 130,000 litres of fuel per day — still only a small portion of Gaza’s estimated daily needs of more than a million litres.

Most of Gaza’s 2.3 million people are crowded into the southern portion of the territory, with more than a million living in UN schools converted into shelters.

To the hundreds of thousands who evacuated from northern Gaza to the south, Israel issued a warning not to return. Northern Gaza has been the focus on Israel’s ground assault.

In leaflets dropped around the south, the Israeli military said it would block such attempts, saying the “the war has not ended yet”, but hundreds of Palestinians could be seen walking north on Friday.

Two were shot and killed by Israeli troops and another 11 were wounded.

Palestinians flee to northern Gaza
Palestinians flee to northern Gaza (Mohammed Dahman/AP)

Israel’s northern border with Lebanon was also quiet on Friday, a day after the militant Hezbollah group, an ally of Hamas, carried out the highest number of attacks in one day since fighting there began on October 8.

Hezbollah is not a party to the ceasefire agreement but had been widely expected to halt its attacks.

The war erupted when several thousand Hamas militants stormed into southern Israel, killing at least 1,200 people, mostly civilians, and taking scores of hostages, including babies, women and older adults, as well as soldiers.

The hope is that “momentum” from the deal will lead to an “end to this violence”, said Majed al-Ansari, a spokesman for the Foreign Ministry of Qatar, but hours before it came into effect, Israeli defence minister Yoav Gallant told troops the respite would be short and that the war would resume for at least two more months.

The Israeli offensive has killed more than 13,300 Palestinians, according to the Gaza Health Ministry, and 6,000 people have been reported missing, feared buried under rubble.

Israel says it has killed thousands of Hamas fighters, without presenting evidence.