DOHA, Qatar >> Israel and Hamas have 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 militants 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 would also flood desperately needed humanitarian aid into a territory ravaged by 15 months of war, mediators say.

The prime minister of Qatar, Sheikh Mohammed bin Abdulrahman Al Thani, said the cease-fire would go into effect on Sunday and that its success would depend on Israel and Hamas “acting in good faith in order to ensure that this agreement does not collapse.” He spoke 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, noting that his administration and President-elect Donald Trump’s team had been “speaking as one” in the latest negotiations.

Israeli Prime Minister Benjamin Netanyahu said late Wednesday that the cease-fire agreement with Hamas is still not complete and final details are being worked out.

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

Netanyahu thanked Trump and Biden for “advancing” the ceasefire agreement, but did not explicitly say whether he has accepted it, saying he would issue a formal response only “after the final details of the agreement, which are currently being worked on, are completed.”

His measured reaction may reflect domestic politics. Netanyahu’s governing coalition depends on the support of two hardline factions whose leaders have threatened to leave the government over the planned release of Palestinian prisoners. Although opposition leaders have vowed to support the ceasefire deal, the loss of his hardline allies could lead to the collapse of the coalition and trigger early elections.

Israeli President Isaac Herzog called on Netanyahu’s government to approve the ceasefire in a nationally televised speech. Hamas said in a statement that the ceasefire was “the result of the legendary resilience of our great Palestinian people and our valiant resistance in the Gaza Strip.”

Mediators from Egypt, Qatar and the U.S. will meet in Cairo on Thursday for talks on implementing the deal, according to a senior U.S. official who was not authorized to comment publicly and spoke on the condition of anonymity.

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 militants 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 militant 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.

“People are crying here. They don’t believe it’s true,” he said.

In Israel, hundreds of demonstrators gathered outside Israel’s military headquarters in Tel Aviv, calling for a deal to be completed. Many held posters of hostages held by Hamas, others hoisted candles in the air.

There is still no plan for who will govern Gaza after the war. Israel has said it will work with local Palestinians not affiliated with Hamas or the Western-backed Palestinian Authority. But it is unclear if such partners exist, and Hamas has threatened anyone who cooperates with Israeli forces.