An eyewitness told the BBC about a terrible moment when the militants stormed the hotel "Intercontinental" in Kabul on Saturday.
A person who did not receive a name for security reasons said that he was saved by saying that he was Afghan. "Where are the foreigners?" They cried.
The death of fourteen foreigners was confirmed along with four Afghans.
The Minister of the Interior said that the recent decision to transfer the security of a private company was a mistake.
About 160 people were rescued after Afghan troops fought all night to regain control of the building.
The authorities said that the three attackers were killed and under siege. 10 people, including four civilians, were injured.
The Kabul police told the BBC that nine Ukrainians, one German, one Greek and one Kazakh citizen were deemed dead. Two have not yet been determined.
The Afghan airline Kam Air claims that several of its employees were killed, and some of them are still missing.
The Taliban, who attacked the hotel in 2011, said that this was the last attack. A spokesman said in a statement by AFP that the group "killed dozens of foreign invaders and their puppets."
Can the Afghan military change the course of the Taliban's struggle?
World powers are fighting for a new "great game" of Afghanistan
"Shooting" ate before shooting '
On Saturday evening, militants stormed a six-story hotel around 9:00 local time (16:30 GMT), and guests enjoyed dinner.
The witness told the BBC that he was having dinner with his son when the militants started shooting small weapons in the air.
They killed a woman who is believed to be an alien, and they themselves shot the witness.
He shouted: "I'm an Afghan." One of the militants shouted that they did not kill the Afghans and demanded to know: "Where are the foreigners?" The men rushed out of the room to find them.
Hasib, another witness, told Tolo News that two of the militants had asked him first to serve them food.
"They wore very elegant clothes," he said. "They came to me and asked me about food, I served them for food, they thanked me and took their places, then they pulled out their weapons and started shooting people."
"Around me there were dozens of corpses."
Several guests were photographed using sheets to try to get off the balcony on the top floor.
Dramatic shots on Afghan television showed thick black smoke and flames that rose from an impressive hotel on top of a hill.
According to the press service of the Ministry of Internal Affairs, Afghan special services were lowered by helicopters to the roof of the hotel at night.
They worked with Western intelligence agencies to put an end to the siege.
The ministry promised to investigate how the attackers violated security, which was transferred to a private company two weeks ago.
The hotel manager Ahmad Haris Nayab said that the militants entered the hotel through the kitchen.
Intercontinental is a state-run hotel, not affiliated with the world-wide network of hotels of the same name, where weddings, conferences and political meetings are often held.
Security has been strengthened in Kabul since last May, when a huge cargo bomb killed at least 150 people.
However, in recent months there have been several attacks. They include a bomb in the cultural center of Shia last month, which killed more than 40 people.