Preventing Afghanistan from again becoming a haven for terrorists who threaten the United States and its allies was the one enduring positive achievement of the past 20 years of war.
But in the final, messy days of the US-led intervention, even that is starting to crumble.
The UK and US on Wednesday warned people to stay away from Kabul airport – the hub of a massive evacuation effort – because of an “ongoing and high risk of terrorist attack”.
The group of most concern is an affiliate of the Islamic State.
Please use Chrome browser for a more accessible video player
Ministers have been warning in recent days about the risk posed by Islamic State Khorasan – or ISIS-K – to British, US and other forces involved in evacuating tens of thousands of Afghans and others desperate to flee the country following a Taliban takeover last week.
With that rescue effort due to finish ahead of a US deadline to withdraw all troops from the country by next Tuesday, the window of opportunity to target the operation is closing and the threat of an attack appears to be growing.
“ISIS hasn’t had a real large attack for some time,” said Karin von Hippel, director generation of the Royal United Services think tank.
“The world is watching this situation right now so they might think this is an opportunity for us to demonstrate some sort of spectacular event.”
ISIS-K emerged around 2015 as part of an expansion of the group’s reach from Iraq and Syria.
Its fighters are thought to number up to 2,200 – though this figure could well be rising given the security vacuum left by departing foreign troops.
They’re mainly based in Kunar and Nangarhar provinces and are responsible for some of the worst acts of carnage in Afghanistan. One attack at a maternity hospital in Kabul last year killed 24 people including mothers and newborns.
Follow the Daily podcast on Apple Podcasts, Google Podcasts, Spotify, Spreaker
The group is led by a militant called Shahab al-Muhajir. Previous leaders have been killed or captured by US and Afghan forces.
Islamic State is also no friend of the Taliban, having opposed how Taliban leaders negotiated with the US in their return to power.
Attacking Kabul airport would have the double effect of harming western forces while at the same time undermining the authority of Afghanistan’s incoming Taliban rulers.
The kind of attack ISIS-K is notorious for conducting is a suicide bombing using a vehicle or an individual armed with a suicide vest, often followed by gunmen opening fire.
British and other troops will be doing all they can to protect themselves and the people awaiting flights. But they must also rely on the Taliban to help with security.
The possibility of western forces dying in a terrorist attack on their way out of Afghanistan at the end of a mission launched in the wake of the 11 September atrocities against the United States in 2001 must sit uncomfortably with British and American leaders.
Al-Qaeda carried out that attack. It too still has a presence on the ground and – unlike Islamic State – retains close ties with the Taliban.