DOHA, Qatar >> Israel and Hamas agreed to pause the devastating war in the Gaza Strip, mediators announced Wednesday, raising the possibility of winding down the deadliest and most destructive fighting between the bitter enemies.

The three-phase ceasefire deal promises the release of dozens of hostages held by fighters in Gaza and hundreds of Palestinian prisoners in Israel, and it will allow hundreds of thousands of people displaced in Gaza to return to what remains of their homes. It also will flood desperately needed humanitarian aid into a territory ravaged by 15 months of war.

The prime minister of Qatar, Sheikh Mohammed bin Abdulrahman Al Thani, said the ceasefire would go into effect on Sunday. He made the announcement in the Qatari capital of Doha, the site of weeks of painstaking negotiations.

U.S. President Joe Biden touted the deal from Washington, saying the ceasefire will stay in place as long as Israel and Hamas remain at the negotiating table over a long-term truce. Biden credited months of “dogged and painstaking American diplomacy” for landing the deal, while noting that his administration and President-elect Donald Trump’s team had been “speaking as one” in the latest negotiations.

The office of Israeli Prime Minister Benjamin Netanyahu said in a statement that the last details were still being ironed out and that it hoped they “will be finalized tonight.”

An Israeli official familiar with the talks who spoke on condition of anonymity said those details center on confirming the list of Palestinian prisoners who are to be freed. Any agreement must be approved by Netanyahu’s Cabinet.

Once the first phase of the deal takes effect, it is expected to deliver an initial six-week halt to fighting along with the opening of negotiations on ending the war altogether.

Over those six weeks, 33 of the nearly 100 hostages are to be reunited with their loved ones after months in captivity with no contact with the outside world, though it’s unclear if all are alive.

It remained unclear exactly when and how many displaced Palestinians would be able to return to their homes and whether the agreement would lead to a complete end to the war and the full withdrawal of Israeli troops from Gaza — key Hamas demands for releasing the remaining captives.

Many longer-term questions about postwar Gaza remain, including who will rule the territory or oversee the daunting task of reconstruction after a brutal conflict that has destabilized the broader Middle East and sparked worldwide protests.

Hamas triggered the war with its Oct. 7, 2023, cross-border attack, which killed some 1,200 in Israel and took 250 others hostage. Israel responded with a fierce offensive that has killed over 46,000 Palestinians, according to local health officials, who do not distinguish between civilians and fighters but say women and children make up more than half of those killed.

More than 100 hostages were freed from Gaza in a weeklong truce in November 2023.

The U.S., along with Egypt and Qatar, have brokered months of indirect talks between the bitter enemies that finally culminated in this latest deal. It comes after Israel and the Lebanese fighter group Hezbollah agreed to a ceasefire in November, after more than a year of conflict linked to the war in the Gaza.

U.N. and international relief organizations estimate that some 90% of Gaza’s 2.3 million people have been displaced, often multiple times. They say tens of thousands of homes have been destroyed and hospitals are barely functioning. Experts have warned that famine may be underway in northern Gaza.

Abed Radwan, a Palestinian father of three, called the ceasefire deal “the best day in my life and the life of the Gaza people ... Thank God. Thank God.”

Radwan, who has been displaced from the town of Beit Lahiya for over a year and shelters in Gaza City, said he hopes to return and to rebuild his home. As he spoke to AP by phone, his voice was overshadowed by the celebrations of fellow Gazans.