Israel and Hamas have reached a deal to exchange 50 of the hostages held in Gaza for a four-day pause in fighting.
The agreement should also see 150 Palestinian women and children held in Israeli jails released and an increase in humanitarian aid allowed into Gaza.
The BBC understands that the pause will start at 10:00 (08:00 GMT) on Thursday.
The US president said the deal would end “an unspeakable ordeal” for the hostages and “alleviate the suffering of innocent Palestinian families”.
The Israeli government vowed to complete its war to eliminate Hamas and return the rest of the more than 200 hostages who Hamas gunmen kidnapped during a cross-border attack on southern Israel on 7 October in which 1,200 people were killed.
Hamas – which Israel, the US and other Western powers class as a terrorist organisation – said the deal would give Palestinians time to recover after an intense Israeli air and ground assault which its government in Gaza has said has killed more than 14,000 people.
Which hostages will be released?
After talks continued into the early hours of Wednesday morning, Israel’s coalition government finally signed off on this deal.
A statement from the office of Prime Minister Benjamin Netanyahu announced that 50 women and children would be released over four days, during which time “a pause in the fighting will be held”.
It also offered Hamas an incentive to release more, saying: “The release of every additional 10 hostages will result in one additional day in the pause.”
That clause is important for the hostages’ families, some of whom had previously told the BBC that they did not want to see a partial deal.
The 50 hostages expected to be released in four batches of 12 will be Israeli nationals or dual nationals, rather than foreigners.
No list of names has been published, but a senior US official told reporters that at least three American citizens – including three-year-old Avigail Idan, whose parents were killed in Kibbutz Kfar Aza – would be among them.
A senior Israeli official said on Tuesday afternoon that Hamas could also unilaterally release the 26 Thai nationals believed to be among the hostages.
The International Committee of the Red Cross (ICRC) has said it is ready to facilitate any releases, as its staff did when Hamas freed two Israeli-American women and two Israeli women last month.
Israeli forces operating inside Gaza have also rescued one female soldier and recovered the bodies of two other female hostages – a soldier and a civilian.
The Israeli government said it would “continue the war in order to return home all of the hostages, complete the elimination of Hamas and ensure that there will be no new threat to the State of Israel from Gaza”.
What will happen in Gaza during the pause?
A longer Hamas statement gave more details of what Israeli military action was expected to cease for the duration of what it called a “hudna”, or temporary truce.
It said all drone and Israeli aircraft activity was expected to stop for four days in the south of Gaza.
But in the north – which has been the main target of Israeli operations to dismantle Hamas – the same will only hold between 10:00 and 16:00 local time (08:00-14:00 GMT) each day.
Israeli troops and tanks are expected to remain in their positions inside Gaza during the four-day pause, but the Hamas statement said Israeli forces would not attack or arrest anyone.
For Palestinians in Gaza, 1.7 million of whom have fled their homes according to the UN, a respite in the brutal fighting cannot come soon enough.
The deal will allow 200 lorries carrying aid, four fuel tankers and four lorries carrying gas to enter Gaza via Egypt’s Rafah crossing on each of the four days.
But it is understood that the boost in fuel – desperately needed for hospital generators, water desalination and sewage facilities – will only last for as long as the pause.
Israel cut off electricity and most water, and stopped deliveries of food, fuel and other goods to Gaza in retaliation for Hamas’s attack.
It has allowed 1,399 lorryloads of humanitarian supplies to enter via Egypt over the past month, compared to a monthly average of 10,000 before the war, according to the UN. It blocked all fuel deliveries until a week ago, saying that it could be stolen by Hamas and used for military purposes.
And although the deal will allow people in Gaza safe passage from north to south, it will not permit the hundreds of thousands of displaced people from the north to return home.
Who are the Palestinian prisoners?
Hamas said that the deal would also see 150 Palestinian prisoners – all women and children – released by Israel.
The Israeli government statement did not mention that, but on Wednesday morning its justice ministry published a list in Hebrew of the names of 300 prisoners eligible for release as part of the deal – based on the possibility that Hamas will agree to free 50 more hostages.
The list comprises 123 boys aged between 14 and 17, one 15-year-old girl, 144 18-year-old men, and 32 women aged between 18 and 59. Most are remanded in custody while awaiting trial on charges that range from stone-throwing to attempted murder.
The reason the list had to be published is because of a legal formality in Israel. Ahead of any prisoner release, Israeli citizens must be allowed 24 hours to make an appeal to the Israeli Supreme Court.
No serious holdups are expected, but this is why there is a delay in the deal taking effect.
Israel is currently holding about 7,000 Palestinians accused or convicted of security offences, according to Israeli and Palestinian rights groups. Almost 3,000 Palestinians are reported to have been arrested in the occupied West Bank and East Jerusalem, where violence has also surged, since 7 October.
Hamas’s statement ended by saying the deal aimed to “serve our people and strengthen their steadfastness in the face of aggression”.
It also warned: “Our fingers remain on the trigger, and our victorious fighters will remain on the look out to defend our people and defeat the occupation.”