The phone calls from the White House came all weekend.
Joe Biden had instructed his team to ensure that Benjamin Netanyahu, the Israeli prime minister, was left in no doubt: America wanted a ceasefire to free the hostages.
The US president was giving personal direction as he worked “hour by hour” on clinching an agreement to exchange the captives for a pause in the Israeli bombardment of Gaza.
Mr Netanyahu had argued that any ceasefire will be used by Hamas to regroup but Washington was warning him he was losing the moral high ground as the Palestinian death count rose.
It is hard to ignore the pressure of your firmest international ally, and Mr Biden was keen to secure the release of some of the nine Americans believed to be among the hostages.
But Mr Netanyahu was also under huge, building pressure from the families of the Israeli hostages desperate to get their loved ones home from the Hamas tunnels.
In the end, the man once known as “Mr Security” agreed to stop the bombs, but only for a matter of days, to secure the hostages’ freedom and allow humanitarian aid into the Gaza Strip.
The deal was on Tuesday night on the brink of being completed, with Mr Netanyahu presenting it to the Knesset, Israel’s parliament.
He said that Mr Biden had been instrumental, too, in making the deal better for Israel – getting them more hostages freed “for a lower cost”.
At times during the six weeks it felt like the delicate diplomatic dance to release any of the estimated 240 hostages would be a step too far.
More than once it had faltered in its tracks. Even as the world waited with bated breath for news of a deal on Tuesday evening, those involved in the negotiations were cautious – it could fail right up to the last moment.
Negotiators endured hours of tension during round the clock talks before the final breakthrough, painfully aware that any escalation in the Gaza Strip could easily derail their high-stakes diplomacy.
“We are now very close, very close,” Mr Biden said, a small smile on his face at the White House on Tuesday afternoon. “We could bring some of these hostages home very soon.”
But raising his hands to stress the point, he said: “I don’t want to get into the details of things, because nothing is done until it’s done.”
As he spoke, almost 7,000 miles away in Israel, Mr Netanyahu was taking the necessary steps to implement the painstakingly composed deal.
The Israeli prime minister held three back-to-back meetings with his war cabinet, security cabinet and government to approve the agreement.
Sources familiar with the negotiations confided that, against steep odds, Israel and Hamas had reached a tentative agreement.
On Tuesday night, it was expected that about 50 Israeli hostages held in Gaza would be released in exchange for more than 100 Palestinian women and children held in Israeli prisons.
The pause in fighting was expected to be four days. Hamas had demanded five, while Israel had wanted only three.
The outline of the deal was put together during weeks-long discussions in Doha, with Qatar acting as a crucial mediator between Israel and Hamas.
The length of any Israeli pause in fighting remained a key point of contention until the final breakthrough.
It had been a long time coming. Earlier this month, Qatari mediators met senior figures from Hamas’s political office.
Then David Barnea, the head of Israel’s Mossad intelligence service, and William Burns, the director of the CIA, held talks with Sheikh Mohammed Bin Abdulrahman al-Thani, the Qatari prime minister.
A six-page document was put together setting out the broad terms of the agreement but as late as Monday, key issues had still not been resolved.
Behind the scenes, Qatari mediators were shuttling proposals and counter proposals between Israeli and Hamas teams in Doha, who never met in person.
Meanwhile, the United States exerted its leverage in a diplomatic blitz, with the president working on the negotiations hour by hour and jumping in personally when he felt necessary.
There were still plenty of details to be ironed out, including the exact number of the hostages to be freed from Gaza and from Israeli prisons.
Talks had already stalled several times before, most recently after Israel raided Gaza City’s Al-Shifa hospital last week.
Qatari mediators acting for Hamas in Doha, met with a wall of silence from Yahya Sinwar, the Hamas leader in Gaza, after the raid.
But over the weekend, Sinwar, who is believed to be hiding in the southern town of Khan Yunis, decided to pick up the phone once again with some fresh demands for the Qatari mediators.
The Hamas leader had agreed to release more than 50 women and children in return for the release of an estimated 150 Palestinian women and children in Israeli jails.
But he has also demanded that Israel limit its drone monitoring of Gaza to six hours a day and that 400 trucks a day be admitted into Gaza, which Israel had vetoed citing security reasons.
On Tuesday night, a compromise appeared to have been reached: Israel would run the flights – but only in north Gaza, not in the south, where Hamas leaders are thought to have fled.
Precious momentum had been regained but was nearly lost after Brett McGurk, the White House’s Middle East coordinator, appeared to suggest that if the deal went ahead it would lead to “a massive surge of humanitarian relief”.
The comments triggered a rebuke from other nations involved in the negotiations, including Ayman Safadi, the Jordanian foreign minister, who said that the aid should come with or without a deal.
The White House national security council was forced to clean up the remarks.
“The United States does not support conditions on the delivery of humanitarian aid into Gaza. We never have, and never will,” said Adrienne Watson, the council’s spokesman.
Domestic concerns were just as influential as high geopolitics in silencing the guns.
Thousands of Israelis, including families of the hostages, had marched from Tel Aviv to Jerusalem demanding Mr Netanyahu secure their release – even at the price of a ceasefire.
Two thirds of those who responded to an opinion poll in Israel supported a prisoner swap.
One grandmother, Kamelia Hoter Ishay, said: “The only thing I am waiting for is the phone call from my daughter, Reuma, who will say: ‘Gali is coming back.” And then I’ll know that it’s really over and I can breathe a sigh of relief.”
There are an estimated 4,800 Palestinians being held in Israel for “security offences” including around 560 serving life sentences for killing Israeli civilians and soldiers.
Many supported the release of all Palestinian prisoners in Israeli jails in return for the hostages.
In the final hours before the breakthrough, key practical challenges had to be overcome, including how to arrange the safe release of the hostages.
There was not only the danger of Israeli air strikes to consider but also the risk of a Hamas double cross, or even the kidnap of the hostages by other terror groups in Gaza.
With the first “humanitarian pause” agreed, international pressure will now build for more pauses and eventually a full ceasefire.
Hamas has undertaken to use the pause to carry out an audit of all the hostages held in their tunnels to establish their locations, which terror group is holding them and if they are still alive.
Negotiators now hope to use the break in the bloodshed to negotiate “phase two”: the release of more hostages in exchange for more pauses.
Achieving real peace after the horrors of Oct 7 will present even more of a diplomatic challenge than today’s success against all the odds.
Before then, the focus will be on hoping the “humanitarian pause” holds without breaking out into renewed violence.