JERUSALEM - Twenty-five hostages have been released by Hamas – 13 Israelis and 12 Thais – as part of a deal that has brought about a temporary pause in hostilities and includes the release of Palestinians imprisoned by Israel.

The 13 Israelis were in the custody of the Red Cross in Egypt, according to Israeli officials and local media reports on Friday.

The Thai prime minister, Srettha Thavisin, said 12 Thai hostages had been released, a development that had not been anticipated during speculation in recent days.

The four-day ceasefire marks the first break in seven weeks of war in Gaza and offers some relief for the 2.3 million Palestinians who have endured intensive Israeli bombardment, and for families in Israel fearful for the fate of their loved ones taken captive during the bloody attack launched last month by Hamas that triggered the conflict.

Aid trucks began entering the Gaza Strip from Egypt about 90 minutes after the ceasefire began at 5am local time. Two of the trucks, representing Egyptian organisations, bore banners that said: “Together for Humanity”. Another said: “For our brothers in Gaza”.

Humanitarian officials said the aid was a fraction of what was needed, and that there were robust procedures to prevent Hamas commandeering fuel and other basics, a concern voiced repeatedly by Israeli officials. An almost total blockade of Gaza by Israel has led to acute shortages of all essentials and “catastrophic” conditions, aid agencies said.

Medical facilities have been wrecked across the territory, and doctors have described trying to treat “overwhelming” numbers of seriously injured casualties with inadequate supplies.

The truce, initially lasting four or five days, was announced early on Wednesday and has raised hopes for a more durable pause in the violence.

The Israeli offensive has killed more than 14,000 people, thousands of them children, according to Palestinian officials. More are thought to be buried under rubble.

Underlining the fragility of the four-day pause, an alert sounded in Israel at 7.15am warning of a possible incoming rocket from Gaza targeting a village in southern Israel, followed by reports of the sound of artillery firing from Israel.

But through the morning and into the afternoon a relative calm seemed to have been established across much of Gaza.

Under the agreement, Hamas is due to free at least 50 of the approximately 240 mostly Israeli hostages it has held since launching attacks into southern Israel on 7 October in which 1,200 people, mostly civilians, were killed. In turn, Israel will release at least 150 Palestinian prisoners and allow up to 300 trucks of humanitarian aid into Gaza.

The hostages would be received individually or in groups by the International Committee of the Red Cross and taken across the border and handed to soldiers who would “meet each hostage and identify them physically … to see that these are the correct people”, Ziv Agmon, a legal adviser to Benjamin Netanyahu’s office, told reporters.

Doctors would perform a “full physical examination” of every hostage, and they would be able to video-call family members in a conversation monitored by professionals.

“This is very important … because we don’t know what they know. Many have family members who are not alive any more, there are children with parents that were murdered, siblings who were also murdered,” he said.

The released hostages would then be flown to medical facilities around Israel, where they would be reunited with their loved ones.

“We hope the picture will be beautiful at the end of the day,” Agmon said, adding that Israel would “follow the agreement”.

Ismail Haniyeh, the leader of Hamas, said in a recording on Friday that the Islamist group was committed to the truce and hostage swap deal as long as Israel was committed as well.

A total of 39 Palestinian prisoners – 24 women, including some convicted of attempted murder for attacks on Israeli forces, and 15 teenagers jailed for offences such as throwing stones – were to be released, Palestinian authorities said.

In the occupied West Bank, families waited anxiously for news of the prisoners due to be released. The exchange of female and child hostages and prisoners was initially scheduled for Thursday afternoon but was postponed as last-minute logistical issues were worked out during 24 hours of frantic diplomacy.

Sources close to the negotiations said Israel had presented a series of late requests for clarification of practical issues, and demanded the full identification of the hostages Hamas intended to release. Communication between the parties has to pass from Israeli officials to Qatar, then to Hamas leaders outside Gaza and finally those inside the territory, a process that slowed any resolution of outstanding issues, the sources said.

The agreement includes a halt to Israeli military flights over southern Gaza, with air activity over northern Gaza restricted to six hours a day. Israel has agreed not to arrest anyone in Gaza for the duration of the truce, according to a Hamas statement.

Hamas is understood to be particularly concerned by the prospect of drone surveillance during the release of hostages, a process that would expose their militants and potentially some of their infrastructure or even the whereabouts of key leaders.

Reports suggest that if the first exchanges go well, and Hamas can locate more female hostages or children, there will be further releases on both sides. Some sources have suggested the ceasefire could last up to 10 days as a result.

The deal, struck after lengthy and complex talks mediated by Qatar, the US and Egypt, comes more than six weeks after the conflict began.

Swaths of northern Gaza have been destroyed, and up to 1 million people displaced. Israel says it has killed thousands of Hamas fighters, without presenting evidence for its count.

Fighting on Thursday had continued at even greater than normal intensity, with Israeli jets hitting more than 300 targets and troops engaging in heavy clashes around the Jabalia refugee camp north of Gaza City.

The Israeli Defense Forces (IDF) told residents of Gaza the war was not over. “The humanitarian pause is temporary,” it said on social media. “The northern Gaza Strip is a dangerous war zone and it is forbidden to move north. For your safety, you must remain in the humanitarian zone in the south.”

A similar message was repeated in leaflets dropped over southern Gaza, where almost all Gaza residents are living after being told to leave the north, where fighting between the IDF and Hamas has been the most intense.

Israel has encircled and attacked northern Gaza and put pressure on all civilians there to leave, which UN rights experts say amounts to a forcible transfer, a crime against humanity.

Despite the warnings, many joyful but wary Palestinians emerged from makeshift shelters at the start of the ceasefire to begin the long journey back to their homes.

In the southern town of Khan Younis, which has been housing tens of thousands of displaced families, streets were packed with people on the move, hundreds of them heading north.

Men, women and children carried their belongings in plastic bags, shopping bags and rucksacks. One family sat on the back of cart piled high with bags and pulled by a donkey. Some people looked up to the sky as if to check for Israeli warplanes.

“I am now very happy, I feel at ease,” said Ahmad Wael, walking along with a large mattress on his head. “I am going back to my home, our hearts are rested, especially that there is a four-day official ceasefire, better than returning to live in tents. I am very tired from sitting there, without any food or water. There [at home] we can live, we drink tea, make bread using fire, and the oven.”

Though the deal has raised hopes of a more durable ceasefire, Netanyahu has vowed it will not end Israel’s campaign to destroy Hamas.

The Israeli defence minister, Yoav Gallant, said during a visit to a naval base on Thursday: “This will be a short respite, at the end of which the fighting will continue intensely, and we will create pressure to bring back more hostages. At least another two months of fighting is expected.”

An officer from the IDF’s southern command, which is in charge of the offensive in Gaza, told the Times of Israel: “We will use most of the time for the sake of readiness and planning the tasks expected of us immediately after the end of the truce. We are preparing to continue attacking with all our strength immediately after the end of the truce.”

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

The militant Islamist movement and militia is not a party to the ceasefire agreement, but was widely expected to halt its attacks.