Islamic State has claimed responsibility for twin attacks at Kabul airport that killed more than 70 people and injured twice as many.
Suicide bombers struck the crowded gates of the airport with at least two explosions, causing a bloodbath among civilians and United States troops and effectively shutting down the Western airlift of Afghans desperate to flee.
Afghan officials say at least 60 of their civilians were killed and 143 injured in the attacks that took place late on Thursday afternoon.
At last count, 12 US service members were thought to have been killed in the blasts - 11 Marines and one Navy medic, according to two US officials.
Video images uploaded by Afghan journalists showed dozens of bodies of people killed in packed crowds outside the airport.
A watery ditch by the airport fence was filled with blood-soaked corpses, some being fished out and laid in heaps on the canal side while wailing civilians searched for loved ones.
Several Western countries said the airlift of civilians was now effectively over, with the US having sealed the gates of the airport leaving no way out for tens of thousands of Afghans who worked for the West through two decades of war.
A Taliban official said at least 13 people including children had been killed in the attack and 52 were wounded, though it was clear from video footage that those figures were far from complete. One surgical hospital run by an Italian charity said it alone was treating more than 60 wounded.
The explosions took place amid the crowds outside the airport who have been massing for days in hope of escaping in an airlift which the United States says will end by Tuesday, following the swift capture of the country by the Taliban.
There was no immediate claim of responsibility for the blasts, but US officials pointed the finger at Islamic State's Afghan affiliate, which has emerged as enemies of both the West and of the Taliban.
A witness who gave his name as Jamshed said he went to the airport in the hope of getting a visa for the United States.
"There was a very strong and powerful suicide attack, in the middle of the people. Many were killed, including Americans," he said.
Zubair, a 24-year-old civil engineer, who had been trying for a nearly week to get inside the airport with a cousin who had papers authorising him to travel to the US, said he was 50 metres from the first of two suicide bombers who detonated explosives at the gate.
"Men, women and children were screaming. I saw many injured people - men, women and children - being loaded into private vehicles and taken toward the hospitals," he said. After the explosions there was gunfire.
The explosion at the Abbey Gate was the result of a "complex attack" that resulted in many US and civilian casualties, Pentagon spokesperson John Kirby said on Twitter.
At least one other explosion detonated at or near the Baron Hotel, a short distance from Abbey Gate.
Taliban official Suhail Shaheen said there were two explosions in a crowded area managed by US forces.
"We strongly condemn this gruesome incident and will take every step to bring the culprits to justice."
The Taliban did not identify the attackers, but a spokesman described it as the work of "evil circles" who would be suppressed once the foreign troops leave.
The US and its allies had been urging civilians to stay away from the airport on Thursday, citing the threat of an Islamic State suicide attack.
In the past 12 days, western countries have evacuated nearly 100,000 people, mostly Afghans who helped them. But they say many thousands more will be left behind following US President Joe Biden's order to pull out all troops by August 31.
The last few days of the airlift will mostly be used to withdraw the remaining troops. Canada and some European countries have already announced the end of their airlifts, while publicly lamenting Biden's abrupt pullout.
"The doors at the airport are now closed and it is no longer possible to get people in," Norwegian Foreign Minister Ine Eriksen Soereide said on Thursday.
"We wish we could have stayed longer and rescued everyone," the acting chief of Canada's defence staff, General Wayne Eyre said.
Biden ordered all troops out of Afghanistan by the end of the month to comply with a withdrawal agreement with the Taliban negotiated by his predecessor Donald Trump. He spurned calls this week from European allies for more time.
The abrupt collapse of the Western-backed government in Afghanistan caught US officials by surprise and risks reversing gains, especially in the rights of women and girls, millions of whom have been going to school and work, once forbidden under the Taliban.
Biden has defended the decision to leave, saying US forces could not stay indefinitely. But his critics say the US force had been reduced in recent years to just a few thousand troops, no longer involved in fighting on the ground.
Those that were killed on Thursday were the first to die in action in Afghanistan in 18 months.
Violence from Islamic State creates a headache for the Taliban who have promised that their victory will bring peace to Afghanistan at last.
Fighters claiming allegiance to Islamic State began appearing in eastern Afghanistan at the end of 2014 and have established a reputation for extreme brutality.
Australian Associated Press
Sign up for our newsletter to stay up to date.