AS THE AUGUST 31st deadline to conclude the evacuation of Afghanistan loomed, the drumbeat of warnings grew louder. On August 24th President Joe Biden warned of an “acute and growing risk” of a terrorist attack, by the local branch of Islamic State (IS), against Kabul’s airport, thronged by thousands of Afghans desperate to escape the Taliban’s rule. On August 25th several governments told their nationals to keep away from the airport. On August 26th a British minister warned that intelligence pointed to “a very imminent, highly lethal attack”. Alas, it came later that afternoon.

At least 13 American troops and at least 60 Afghans were killed in two suicide-bombings, which the Pentagon described as a “heinous” and “complex” attack. General Kenneth McKenzie, head of America’s Central Command, which has responsibility for Afghanistan, said that the Pentagon was “still working to calculate the total loss”. One attack targeted the Abbey gate into Kabul airport, where many would-be refugees had gathered in a sewage canal (see map). The other struck the Baron hotel, 200 metres away, where British officials had been processing Afghan claims. Gunmen opened fire after both incidents.

The American casualties were the country’s first military deaths in combat in Afghanistan since February 2020 and the heaviest in that country since a Chinook helicopter was shot down a decade ago, killing all 38 people on board, of whom 30 were American military personnel. In a press conference held hours after the attacks, a visibly emotional Mr Biden described the victims as “heroes…engaged in a dangerous, selfless mission to save the lives of others”.

General McKenzie blamed the Kabul attacks on Islamic State Khorasan Province (ISKP), a branch of the IS group that established a short-lived caliphate in Iraq and Syria between 2014 and 2018. IS claimed responsibility for the attack in a report by Amaq, an IS-linked news agency, which pictured the alleged suicide-bomber. General McKenzie said that more attacks were expected.

The bombings came as the American-led evacuation effort was entering its final, frantic days. Several countries, including Germany and the Netherlands, have wound up their flights; France is preparing to do so. Speaking after the attack, Boris Johnson, Britain’s prime minister, struck a defiant tone, insisting that his country would press ahead with evacuations. “What this attack shows is the importance of continuing that work in as fast and as efficient a manner as possible in the hours that remain to us,” he said. “We will get our Afghan allies,” promised Mr Biden, “and our mission will go on. America will not be intimidated.”

Yet there were signs that Kabul’s airport was turning into an impenetrable fortress for the Afghans crowded outside. The MilitaryTimes, a website, reported that troops inside the airport were welding its gates shut. In the coming days, America may be forced to rely on CIA and military helicopter flights out of the airport to recover the remaining American citizens who wish to leave. On August 25th the State Department estimated that these people may number a few hundred.

America may also be hastening its departure. After further large explosions were heard around the airport on August 26th, a Taliban spokesman clarified that America was destroying equipment. Many thousands of vulnerable Afghans, who had once worked with coalition forces, were already bound to be left behind; even more may now miss out. “I know of no conflict, as a student of history,” said Mr Biden, “where, when a war was ending, one side was able to guarantee that everyone that wanted to be extracted from that country would get out.”

That ISKP would seek to mount such an attack was all too tragically predictable. “It has positioned itself from the outset as a Taliban rejectionist movement,” says Asfandyar Mir of Stanford University. Whereas the Taliban is rooted in the Hanafi sect of Islam, ISKP—like al-Qaeda—draws its inspiration from the Salafi tradition, which is strong in Afghanistan’s eastern provinces. “Its go-to strategy has been outbidding violence,” says Mr Mir. “The fundamental premise of the group is that there are all these other organisations which don’t punish non-believers…and they need to be punished”.

That has led it to unleash unmatched savagery, much like its parent organisation did in Syria and Iraq. In May 2020, for instance, the group is thought to have attacked the maternity ward of Kabul’s Dasht-e-Barchi hospital, killing 24 people, including two children. In May this year it allegedly targeted the Sayed Al-Shuhada school in a part of the capital populated by the Shia Hazara minority, killing some 90 people, most of whom were schoolgirls. A month later it killed ten humanitarian workers removing mines in Baghlan province, to the north of Kabul. Though the group lost almost 12,000 operatives between 2015 and 2018 in the face of intense counter-terrorism pressure from America and the former Afghan government, recent UN reports suggest that it still has somewhere between 500 and 1,500 fighters in the country.

America is now in the curious position of making common cause with insurgents whom it fought for 20 years, against a shared enemy. General McKenzie said that there was no evidence that the Taliban had “let this happen”. He said that America had supplied the group with intelligence—Bill Burns, the CIA chief, met a senior Taliban leader in Kabul on August 23rd—and that the Taliban had thwarted earlier attacks on American troops. “They want to reclaim the airfield,” he added. “So we share a common purpose…they’ve been useful to work with.”

Mr Biden argued that the attack vindicated his determination, opposed by allies, including Mr Johnson, to hold firm to the August 31st deadline, which was shortened from an earlier target of September 11th. This, he said, is “why I’ve been so determined to limit the duration of this mission.” Mr Biden has long been leery of committing American troops overseas, and his White House reckons that because leaving Afghanistan is popular (though less popular than it was before troops actually started leaving), he will not pay a political cost. Mr Biden threatened ISKP with retribution, saying that he had asked commanders for a list of potential targets: “We will not forgive, we will not forget, we will hunt you down and make you pay”.

Yet his critics will see the attack as a repeat of past American fiascos, from the hostage crisis in Iran in 1979 to the assault on America’s consulate in Benghazi, Libya, in 2012. Ben Sasse, a Republican on the Senate’s intelligence committee, described the bombings as the “nightmare we feared” and demanded that Mr Biden “rip up the August 31st deadline and defend evacuation routes”. Kevin McCarthy, the top-ranking Republican in the House, demanded that Congress “prohibit the withdrawal of our troops until every American is safely out”—a condition that the Taliban has already rejected. Jim Inhofe, the top Republican on the Senate Armed Services committee, said that “President Biden alone made a strategic decision, and that decision led to the tragic events today.”

For Afghans, reeling from the Taliban’s lightning victory 11 days ago, the attacks heaped tragedy upon tragedy. The Islamists’ inability to secure the city against another massacre suggests that they may have no stronger a grip on things than the government they toppled. “Kabul is hidden in the noise of ambulances,” wrote Ziar Khan Yaad, a journalist at TOLONews, a news channel. “Jets are flying in the sky and there is blood on the ground. The families of the victims shed tears in front of the emergency hospital.”