The nationalities of those victims were not immediately known, but a spokesman for the Interior Ministry said most of the foreigners worked for Kam Air, a private Afghan airline, and one was from Ukraine.
In Kiev, Ukrainian Foreign Minister Pavlo Klimkin tweeted that six Ukrainians had been reported killed in the attack.
The high-profile assault on the Intercontinental Hotel, a heavily guarded hilltop building that survived Soviet occupation, civil war and Taliban rule, was the latest in a string of deadly gun and bombing attacks in the capital that have targeted government intelligence facilities, hotels, mosques and other locations.
The Intercontinental is a frequent site for conventions, banquet and social events and is popular with foreign visitors. It was hosting a wedding and a meeting of government information and technology employees when the attackers stormed the compound Saturday night.
Security officials said all five attackers were killed by early Sunday after a sustained gun battle that erupted repeatedly throughout the night. Smoke and flames billowed from the building and helicopters hovered overhead, while armed security teams entered and cleared the seven-story building one floor at a time.
A spokesman for the Taliban insurgents, Zabiullah Mujahid, claimed responsibility for the attack in a telephone interview. He said it was aimed at "citizens of occupying nations" and their "Afghan collaborators."
The attack came despite a spate of renewed efforts to revive long-stalled peace talks between the Taliban and the government of President Ashraf Ghani, including reports of private meetings with Taliban emissaries.
International officials sharply denounced the attack and its deliberate targeting of civilians. U.S. Ambassador John R. Bass called it a "heinous" assault and said Afghanistan "deserves peace and security, not deliberate and murderous attacks on innocent civilians."
The U.S. Embassy had issued a warning Thursday that "extremist groups may be planning an attack against hotels" in Kabul.
Tadamichi Yamamoto, the U.N. special Representative for Afghanistan, said the "egregious" attack "may amount to a war crime." He said it was a "moral outrage that the Taliban entered the hotel with the intention of killing civilians."
The government of Pakistan issued a statement strongly condemning the attack, but a spokesman for the Afghan government's chief executive, Abdullah Abdullah, charged that the attack was carried out by the "Pakistan-based Haqqani Terrorist Network."
The Trump administration has repeatedly accused Pakistan of harboring the Haqqani militants, which it denies. This month the White House suspended more than $200 million in military aid to Pakistan, saying it had failed to take steps to rein in the Taliban faction.
Najib Danesh, a spokesman for the Interior Ministry, said the five attackers slipped into the hotel through the kitchen. At least two were killed Saturday night, but the others continued exchanging gunfire with Afghan forces for hours while guests waited fearfully in their rooms and took cover in event salons.
The Intercontinental came under attack from insurgents in 2011, when 11 people were killed in a five-hour siege that sent dinner guests hiding under their tables while gunmen stalked the dining room. Insurgents have also attacked the heavily fortified Serena Hotel in central Kabul.
Constable reported from Islamabad.