US President Joe Biden is facing the worst moment of his presidency. Thirteen US troops and at least 60 Afghan civilians have been killed in a suicide bomb attack outside Kabul's main airport, for which Islamic State has claimed responsibility.
He, like presidents before him, must face several uncomfortable questions. Could an attack on American forces, in such perilous circumstances as those in Kabul right now, have been foreseen?
Was Biden careless in his haste to get American troops out of Afghanistan and end his country's longest war?
Was it a failure of judgment to set an August 31 deadline for the withdrawal of troops?
Could more have been done to protect the perimeter of Kabul airport, and prevent suicide bombers approaching American forces who were engaged in a humanitarian exercise to help evacuate US citizens and visa holders?
Why was the fortified Bagram airbase, built up by the US over decades, not maintained, instead using the vulnerable Kabul civilian airport?
Questions around Biden's judgment and those of his advisers risk eating into his presidency in a way that will erode his authority.
In his moments of reflection, Biden might cast his mind back to other presidents who have endured similar catastrophes.
In 1983, Ronald Reagan was obliged to explain to the country how 241 American service personnel could have lost their lives in a vicious truck-bombing in Beirut, believed to have been carried out by Iranian-backed Shiite militants.
Then, as now in Biden's case, Reagan was blamed for not ensuring US servicemen were adequately protected in their barracks near Beirut airport.
Reagan soon thereafter withdrew American forces from Lebanon, where they were seeking to establish order after Israel's invasion in 1982. Reagan said at the time he would never again send ground troops anywhere in the Middle East.
His successors might have heeded his words.
Biden's political adversaries, including former president Donald Trump, are mercilessly capitalising on a terrible day for the United States and those who look to Washington for leadership in a troubled world.
This is a very bad day for the Western alliance.
The question now becomes: how does Biden respond to this latest in a long history – going back decades – of sickening episodes in its entanglement in the Middle East?
This includes the September 11 bombings in New York and Washington by al-Qaeda terrorists that led to the greatest loss of life from a terrorist attack on American soil in the country's history.
The 20th anniversary of that moment will again rub raw American memories about a day when the world shifted, and prompted decisions that have proven disastrous.
America's attempts, over two decades in Afghanistan, to bring order to a country that has defied attempts by outsiders over millennia to tame its unruly elements have ended in failure.
Likewise, America's rush to war in Iraq, rather than stabilising an inherently unstable Middle East, further catapulted the region into chaos.
All this has come at an immense cost to the United States in blood and money.
Clearly, America's credibility, and that of the Biden presidency, has been diminished by strategic and tactical failures relating to its decision to leave Afghanistan without ensuring an orderly exit strategy.
Claims no-one could have foreseen the speed with which the Taliban would overrun Afghan government forces do not say much for US intelligence on the ground.
In an emotional speech, Biden uttered words and sentiments that have been characteristic of these moments of American trauma when a superpower has been wounded by an act of terror.
We will not forgive, we will not forget. We will hunt you down and make you pay.
In the circumstances, those words are to be expected. No American leader at a moment of national trauma would do otherwise.
However, the task of hunting down those responsible among an amorphous terrorist franchise in Afghanistan and in the wider region will be easier said than done.
Jihadists of whatever stripe across the entire Middle East and beyond will be emboldened.
In Afghanistan, a witch's brew of terrorist groups is evolving, including the al-Qaeda-affiliated ISIS-K terrorist group, which has claimed responsibility for the Kabul suicide bombings.
What makes the apparent lack of security preparedness around Kabul airport surprising is that multiple warnings had been received that ISIS-K was planning to strike Americans as they departed.
Indeed, as recently as Sunday of this week, Biden's national security adviser, Jake Sullivan, described the ISIS-K threat as "acute" and "persistent". Those words are certain to be thrown back in the faces of US officials responsible for securing Kabul airport.
In the meantime, the test for America, as Biden stated, will be to complete its mission to remove its personnel from Afghanistan and to put behind it a bitter moment.
This includes expenditures of something like $2.6 trillion and deaths of 2,442 servicemen and women, not to mention those wounded and damaged by the experience.
In all of this and in sympathy for the hand Biden has been dealt, America was never going to prevail in Afghanistan. It became trapped in a war that was unwinnable.
Documents secured by The Washington Post and published in 2019 showed military commanders in Afghanistan knew it was a losing proposition, yet America stuck it out.
It did so until Trump reached a deal with the Taliban in 2020, which effectively sidelined the regime in Kabul, to have American forces out of Afghanistan by May 1. Biden shifted that end date to August 31.
The Trump agreement with the Taliban spelled the beginning of the end for the Kabul regime of Ashraf Ghani.
What is left now for America and its NATO allies in Afghanistan is to make the best of the chaos that surrounds efforts to stage an orderly withdrawal.
Since there is little or no prospect of American re-engagement in Afghanistan, the world will observe what is certain to be continued bloodletting and risks of an exploding refugee exodus.
The next chapter in Afghanistan may well dwarf what has happened in Yemen where a civil war has decimated the country and impoverished a population that had in any case been living on the edge.
Tony Walker is a vice-chancellor's fellow at La Trobe University