It is difficult to claim that the Biden administration’s panicky, slapdash, humiliating exit from Afghanistan — dependent on the kindness of the Taliban and commemorated by indelible images of chaos and betrayal — is really the best we could do. This requires a Trumpian level of sycophantic self-delusion. Or it represents a belief that an arrogant imperial power deserves public punishment. This is self-flagellation masquerading as foreign policy.

The future of Afghanistan was determined the moment President Biden decided to honor President Donald Trump’s “peace” agreement, which effectively ratified the Taliban’s right to rule. The Afghan government was not even a party to the treaty. And when Biden announced the final departure date for U.S. troops, the calculations of every member of the Afghan military shifted.

They were fighting for an outcome — a military stalemate against the Taliban — that their main patron viewed as hopeless. Afghan soldiers knew that resistance against a ruthless enemy could bring death, not only to themselves, but to their families. Why take that risk for a result the United States had already declared improbable? The cutoff of U.S. air support and logistical assistance hammered home the point.

Both the Biden and Trump administrations justified their actions by presenting a binary choice: endless combat or immediate retreat. The U.S. military, in contrast, was seeking options along that continuum — trying to find a sustainable role that would backstop the Afghan military while allowing for aggressive counterterrorism.

Yet Biden, like Trump, wanted a decisive, high-profile American departure. This took a difficult, medium-term problem and turned it into a catastrophic symbol of betrayal and defeat. Decisive presidential leadership is often a virtue. In this case, living with ambiguity and watching developments might have been the better option.

But the deed is done. And the Biden administration — and all that follow it — will need to deal with a brutal fact of history. Those who planned, carried out and supported the attacks of Sept. 11, 2001, can now claim, with some credibility, that they succeeded. Terrorists protected by the Taliban took nearly 3,000 innocent lives, caused anywhere from $2 trillion to $3 trillion in economic damage and encouraged a generation of American recrimination and self-doubt, all for about $500,000 — the money it took to mount the operation.

Yes, plenty of al-Qaeda operatives got removed from the organizational chart along the way. But for those who value martyrdom, death is not so much a deterrent as an inspiration. It’s the outcome that matters. And now, the Taliban flag flies again above Kabul.

This is not a full or accurate depiction of events. By the most important measure — preventing a series of escalating attacks on the American homeland — the war against terrorism has generally been successful. All the money spent on airport and port security, on the gathering of intelligence, on the hardening of prospective targets, on the tracing and disruption of terrorist financing, on shoring up law enforcement and on military strikes against terrorist groups have made the work of terrorism far more difficult.

But those of us who served in government at the time of the 9/11 attacks are haunted by a hypothetical. We know that if Osama bin Laden had been given access to chemical, biological or radiological materials, he would have used them. And we know that the state sponsorship of terrorism is the most likely route for such proliferation to take place.

Biden has justified the withdrawal from Afghanistan, in part, as way to make our response to emerging threats wider and nimbler. He has argued that the United States’ “over the horizon” capabilities to preempt terrorist activities are much better than they were 20 years ago, and sufficient to the dangers we currently face. Much depends on the answer to the question: Is Biden announcing an active intention or making an excuse for retrenchment?

Biden knows from his morning intelligence briefing that ending the “forever war” cannot be done unilaterally. Anyone who tries is given a name tag reading “target.” The war may flare in Afghanistan, Somalia, Nigeria or some other place where local threats take on global ambitions. But it won’t end until the threat of terrorism ends.

The United States now enters a high-stakes race between its over-the-horizon technologies and the talent of terrorists. Biden’s national security adviser, Jake Sullivan, may be right that “the relevant terrorist groups in Afghanistan do not possess advanced external plotting capabilities.” But in that country, al-Qaeda is not a parasite feeding off the Taliban; it is an integral part of the regime. The United States’ capitulation to the Taliban is sure to encourage a new generation of young, bright and ambitious mass murderers. And when a terrorist group is hosted by a nation, capacities may be quickly gained.

As the 20th anniversary of 9/11 approaches, unlearning its lessons would be a dangerous way to honor it.