President Jimmy Carter spent his last hours in office on Jan. 20, 1981, negotiating the release of 52 American hostages held in Iran, but they did not head home until shortly after Ronald Reagan had been inaugurated. In similar fashion, President Joe Biden and his aides have spent their last days in office negotiating the release of Israeli hostages from the Gaza Strip — and most of those hostages will not come home until after Biden has left the White House.

On Wednesday, Israel and Hamas finally agreed on a complex, long-delayed deal that will result in at least a temporary ceasefire in Gaza after 466 days of war. Assuming that the Israeli cabinet approves, the first stage of the deal will see 33 Israeli hostages — an unknown number of whom are still alive — released in return for a still-to-be-determined number of Palestinian militants held in Israeli prisons.

This is an important achievement, but only a partial one. Israel believes 98 hostages remain in Gaza and that about 60 of them are alive. Ending the war and releasing the remaining hostages will be a challenge for President Donald Trump and his team.

But although Trump is not yet inaugurated, he is already taking a victory lap for this deal — and deservedly so.

In a highly unusual level of cooperation between outgoing and incoming administrations of different parties, Trump’s Middle East negotiator, Steve Witkoff, joined Biden administration representatives at the hostage-release negotiations in Doha, Qatar.

Trump had threatened “all hell to pay” if the hostages were not set free, but hell had already descended on Gaza shortly after Hamas’s barbaric assault on Israel on Oct. 7, 2023. Most of the territory’s buildings have been damaged or destroyed, and Palestinian health officials report that more than 46,000 people — a figure that does not distinguish combatants from civilians — have been killed since the start of the fighting. (A new study suggests the actual death toll is 40 percent higher.)

Trump’s push for a hostage release might have been more important not in pressuring Hamas — the Israeli assault has already done that — but in finally persuading Israeli Prime Minister Benjamin Netanyahu to conclude a deal very similar to one that had been on offer since May. National Security Minister Itamar Ben Gvir, one of Netanyahu’s far-right coalition partners, bragged on X on Tuesday about his party’s success in blocking previous deals: “In the past year, through our political power, we succeeded in preventing this deal from moving forward time and time again,” he wrote.

That is nothing to boast of, given how many Palestinian civilians, and probably Israeli hostages, died in the meantime. (On June 1, the death toll in Gaza stood, according to Palestinian health officials, at a little over 36,000, so the seven-month delay might have cost roughly 10,000 lives.)

Trump’s desire to get a deal done before he enters office strengthened Netanyahu’s hand within his own government and made him more likely to finally reach an agreement with Hamas. Trump has a lot of leverage over Netanyahu, who has close ties with the Republican Party, and he showed a willingness to use it.

Now the challenge will be to transform a temporary ceasefire into a final end to this terrible bloodshed.

As has been clear for many months, it is in the interests of both Palestinians and Israelis to bring this war to a close.

Israel has inflicted a great deal of damage on Hamas, rendering it incapable of conducting large-scale assaults for the foreseeable future.

Israel’s attacks in Gaza, combined with the offensive it mounted in the fall against Hezbollah, have dealt a massive setback to Iran’s strategy of surrounding Israel with a “ring of fire.” The indirect consequences probably include the fall of the odious Bashar al-Assad regime in Syria. With ruthless application of its immense military power, Israel has revived the deterrence it lost following the costliest single-day attack it has ever suffered.

But Hamas is far from destroyed, despite Netanyahu’s persistence in laying out his scorched-earth war objectives. The terrorist group is actually rebuilding in the rubble under the leadership of Muhammad Sinwar, brother of Yahya Sinwar, the Hamas leader who planned the Oct. 7 attack and was later killed by Israeli forces. On Tuesday, Secretary of State Antony Blinken said, “Hamas has recruited almost as many new militants as it has lost.” (Israel says it has killed 18,000 militants in Gaza.)

The Israel Defense Forces (IDF) keep having to return to areas in Gaza they had previously cleared because Hamas militants pop up every time Israeli troops leave.

Just in the past week, Israel has lost 15 soldiers in northern Gaza, while in the past two weeks, Hamas has fired more than 20 rockets at Israel. “We are in a situation where the pace at which Hamas is rebuilding itself is higher than the pace that the IDF is eradicating them,” Amir Avivi, a retired Israeli brigadier general, told the Wall Street Journal. “Mohammed Sinwar is managing everything.”

The only way to break out of this cycle of violence is to create a moderate government in Gaza capable of keeping the peace and preventing Hamas from staging a resurgence.

It is far from clear whether the Palestinian Authority, even one that is reformed and bolstered with outside assistance, could ever control Gaza, but it is also obvious that there is no real alternative.

Arab states, for one, have made clear that they will not provide funds for rebuilding unless the Palestinians are in charge.

The Saudi government has also said that any progress on a deal recognizing Israel — which both Trump and Netanyahu ardently desire — is now contingent on Israeli recognition of a Palestinian state.

But Netanyahu still will not agree to any role for the Palestinian Authority, and even the United Nations Relief and Works Agency (UNRWA), the primary source of humanitarian aid for Gazans, could be forced to stop work within weeks under a new Israeli law prohibiting any support for Palestinian Authority operations. (Some UNRWA employees are alleged to have taken part in the Oct. 7 attack.) Israeli officials are also determined to maintain a military presence in Gaza — a condition that would be anathema to Hamas.

Therefore, who will govern Gaza in the future remains murky.

That is the subject of the second phase of negotiations between Israel and Hamas, which are slated to start 16 days after the initial ceasefire deal.

Barring an agreement, the war could resume, sowing seeds of hatred on both sides that would be harvested for generations to come.

If Trump can actually force a deal that paves the way for enduring peace in Gaza, rather than just a temporary ceasefire, he might well deserve the Nobel Peace Prize he is said to covet. But to do so, Trump will once again have to pressure Israel, not just Hamas.

Max Boot is a Washington Post columnist and a senior fellow at the Council on Foreign Relations.