Live updates: Follow the latest news on Israel-Gaza
The Hamas-Israel hostage deal capped weeks of tortuous negotiations that were fraught with distrust, hard bargaining, brinkmanship and, sometimes, days of frustration when Hamas leaders just went off the grid, officials familiar with the process told The National.
Fifty Israeli hostages held by Hamas in Gaza in return for 150 Palestinians held in Israeli jails – those are the conditions so far for a four-day truce in the 46-day war in which more than 13,000 Palestinians have been killed.
Qatar, together with Egypt and the United States, mediated the agreement.
"The path to this agreement was not easy, and the path to what comes after it will not be easy," Qatar's spokesman for the Foreign Ministry Majed Al Ansari wrote on X, formerly known as Twitter.
Crucial to the successful conclusion of the negotiations was a meeting held on Monday in the West Bank city of Ramallah, the seat of the Palestinian Authority, said the Egyptian officials.
The meeting was attended by negotiators from Egypt, the United States, Israel and representatives of the Palestinian Authority.
Late on the same day, Hamas leader Ismail Haniyeh said he had submitted the group's final response to the Egyptian and Qatari mediators, leading to speculation that an announcement of an agreement would be made within hours.
The officials said the Ramallah meeting, which lasted about four hours, put the final touches on what was then a draft deal. The meeting also touched on governance and security in the Mediterranean enclave once a permanent ceasefire is reached.
There was a sense of urgency to Monday's meeting after Yemen's Iran-backed Houthis the previous day commandeered a cargo ship in the Red Sea, reportedly linked to an Israeli billionaire, in a serious escalation of the conflict that threatened to disrupt a major trade and oil shipping route.
The seajacking of the Galaxy Leader was the start of similar actions in support of the Palestinians, according to the Yemeni militia, and would stop only if a ceasefire was agreed.
The ominous prospect of a major disruption to shipping in the strategic Red Sea and the Suez Canal to the north was of particular concern to the Egyptians, who rely heavily on the Suez Canal's foreign currency revenue, and to the Americans, who have been trying, with the help of allies, to deny Iran and Russia a foothold in the Red Sea.
The Egyptian officials, recounting the ups and downs of nearly six weeks of negotiations, said Israel's initial disinterest in any negotiations and later its repeated rejection of Hamas's conditions had contributed to the delay in reaching a deal.
They said the right-wing government of Prime Minister Benjamin Netanyahu was taking a hard-line position on the negotiations in the hope that it could buy time to improve its negotiating position, in the event its military scored a high-profile victory over Hamas, capturing a senior Hamas commander or seizing a major command centre.
Representatives of Israel's Mossad and Shin Bet – Israel's intelligence and domestic security agencies, respectively – were generally more responsive and flexible in the negotiations than Mr Netanyahu's government, considered the most right-wing in Israel's history.
Instead, "the government wanted to press on with bombarding Gaza until it achieved its declared aim of annihilating Hamas and its military capabilities," one of the officials said.
Another cause for delay, according to sources, was Hamas's time-consuming commitment to keep Iran, its main backer, the sister of its military wing in Lebanon, and other Gaza-based militants abreast of the progress of the negotiations.
The negotiations involved top intelligence officials or senior diplomats from Israel, Qatar, Egypt, and the United States. Hamas leader Yahya Al Sinwar and his deputy Saleh Al Aroury represented the militant group.
Messages from Qatar to Hamas negotiators in Gaza were relayed by Egypt, which borders Gaza and Israel. US President Joe Biden was informed first hand of the progress of the negotiations through calls with the leaders of Qatar, Egypt and Israel.
Mr Al Sinwar's own security concerns and his outrage at rising Palestinian casualties also played a part in delaying the process and contributed to the complexity of the negotiations.
The Hamas leader in Gaza, a 61-year-old veteran of the group's military wing, would occasionally stop taking calls for days, either to protest against what he viewed as Israeli atrocities in Gaza, like shelling schools or storming a hospital, or for security reasons, the officials confirmed.
Mr Al Sinwar, who was jailed by Israel for more than 20 years, routinely had aides schedule calls from Egyptian and Qatari mediators or fellow Hamas leaders like Ismail Haniyeh.
"He used secure lines, which he often changed, and sophisticated jamming devices to avoid exposing his location to Israelis," one of the officials said. He often communicated with Hamas's field commanders through coded written messages.
At least once the negotiations were disrupted because the Hamas negotiators lost contact with field commanders in charge of hostages or simply because the whereabouts of the captives could not be ascertained due to their movement to avoid Israel's relentless bombardment, the officials said.
Throughout the negotiations, Mr Al Sinwar used coded language for the day and time he would make or receive calls. He also used different aliases, the officials said.
The Israel-Hamas deal provides a four-day pause in fighting to allow the release of up to 50 hostages held by Hamas in Gaza in exchange for 150 Palestinian women and children imprisoned in Israel and the entry of substantial humanitarian aid, including fuel, into the besieged enclave.
The deal, expected to start on Thursday or Friday, follows nearly seven weeks of devastating Israeli bombardment and a ground offensive in Gaza, which killed more than 14,000 Palestinians, injured tens of thousands, and displaced two thirds of the enclave's 2.3 million residents.
The fighting, triggered by a deadly rampage in southern Israel by Hamas on October 7, and a total blockade of Gaza by Israel combined to create a major humanitarian crisis in densely populated Gaza.
The exchange of prisoners would be staggered over the duration of the truce, an arrangement that was demanded by Hamas to ensure Israel's reciprocity. The truce could be extended if the release of hostages continues, according to Israel.
Representatives of the International Committee of the Red Cross, the officials said, would receive hostages at locations selected by Hamas's field commanders and not relayed to the ICRC delegates until shortly before the designated time to pick them up.
They said Hamas, at Israel's insistence, has agreed to allow the ICRC to visit all the civilian hostages it has, but only under stringent security precautions to prevent a possible leak of actionable intelligence.