An eyewitness has told the BBC of the terrifying moment gunmen burst into Kabul's Intercontinental Hotel restaurant on Saturday.
The man, who is not being named for security reasons, said he was spared after saying he was an Afghan. "Where are the foreigners?" they shouted.
Fourteen foreigners are confirmed to have died, along with four Afghans.
The interior minister said the recent decision to transfer security to a private company had been a mistake.
Some 160 people were rescued after Afghan troops fought throughout the night to regain control of the building.
Three attackers were also killed in the siege, officials said. Ten people, including four civilians, were injured.
Kabul police told the BBC that nine Ukrainians, one German, one Greek and one Kazakh citizen had been confirmed dead. Two have yet to be identified.
Afghan airline Kam Air says a number of its employees were killed and some are still missing.
The Taliban, which targeted the hotel in 2011, says it was behind the latest attack. A spokesman said in a statement quoted by AFP that the group had "killed tens of foreign invaders and their puppets".
Gunmen 'ate before shooting'
The gunmen burst into the six-floor hotel at around 21:00 local time (16:30 GMT) on Saturday evening, as guests were enjoying dinner.
The eyewitness told the BBC he was having dinner with his son when the gunmen began firing into the air with small arms.
They killed a woman – believed to be a foreigner – and turned the gun on the eyewitness himself.
He shouted "I'm Afghan". One of the gunmen shouted that they didn't kill Afghans and demanded to know "Where are the foreigners?" The men then ran out of the room to look for them.
Haseeb, another eyewitness told Tolo News that two of the gunmen had asked him to serve them food first.
"They were wearing very stylish clothes," he said. "They came to me and asked for food. I served them the food and they thanked me and took their seats. Then they took out their weapons and started shooting the people."
"There were dozens of dead bodies lying around me."
Several guests were pictured using bed sheets to try to climb down from a top-floor balcony.
Dramatic images on Afghan TV showed thick black smoke and flames rising from the imposing hilltop hotel.
Image captionThe hotel is a landmark in Kabul
Image captionSeveral ambulances were on hand to transport the wounded to hospital
Afghan special forces were lowered by helicopters on to the roof of the hotel during the night, an interior ministry spokesman said.
They were working with Western special forces to bring the siege to an end.
The ministry has promised an investigation into how the attackers breached security, which was handed to a private company two weeks ago.
Hotel manager Ahmad Haris Nayab said the gunmen had entered the hotel through a kitchen.
The Intercontinental is a state-owned hotel – not linked to the global hotel chain of the same name – which often hosts weddings, conferences and political gatherings.
Security has been tightened in Kabul since last May, when a huge truck bomb killed at least 150 people.
However, there have been several attacks in recent months. They include a bomb at a Shia cultural centre last month that killed more than 40 people.
- Sam George: Lack of bed and ambulance led to death of a 12-year-old
- Ordering loophole allowed students to eat for free at KFC for six months
- Woman attacked by wild antelope succumbs to death
- Ernest Ako (Former IGP)
- Parliament will carry out its own investigation into alleged assault on Citi FM journalists – James Agalga
- Accounts of how some people are treated by National Security shocking – Samson Lardi
- Playback: Newsfile discusses alleged assault on Citi FM journalists, Otumfuo joins ‘galamsey’ fight
- Social media reacts to Affail Monney’s apology on Citi FM journalist’s breach of ethics comment
- I’m surprised DSP Azugu is still at post after Ayawaso West Wuogon violence – James Agalga
- Complaints by aggrieved KATH staff have been resolved – Head of Surgery Directorate
Greed, dishonesty and hypocrisy must be eschewed in ‘galamsey’ fight – Asantehene
Emotional Stephen Appiah tears up talking about son Rodney
Attacks on journalists: Seek help from international bodies if national agencies fail to address problem – Ken Ashigbey
Shun party politics at the workplace – Central Regional Minister
GPL: Four games to lookout for on matchday 25
Wesley Girls no fasting policy: Peace Council calls on Ghanaians to be circumspect in pronouncements
Israel strike in Gaza destroys building with AP, other media
Chinese busted for mining at River Pra by military task force
Rotary Club builds classroom block for Yahima SDA
Government must involve local communities in anti-galamsey campaign – Galamsey Researcher
We’ll fully cooperate with Energy Minister to facilitate lifting of new LPG outlets ban – LPG Marketers Association
Covid-19 has affected blood mobilisation – Dr Srofenyo
We have $200m for you to borrow – ECOWAS Bank to governments, businesses
Ban on drumming and noisemaking imposed in Korle-Klottey as preparations towards Homowo begin