The attack began around 6 pm and bursts of gunfire could be heard from inside the Serena hotel as Afghan troops cordoned off the area.
The Taliban claimed responsibility, saying its fighters targeted foreigners and dignitaries gathered at the hotel for a celebration marking the Persian new year, Nowruz.
A hotel worker named Gulam Ali told his brother over his cellphone that all the guests and staff members had taken refuge in the basement.
"Foreigners, workers, everybody is in the basement. A quick-reaction unit from the police entered the Serena and the hotel is surrounded."
Also Read
Interior Ministry spokesman Sediq Sediqqi described the attackers as young men who appeared to be about 18 years old and said all had been killed.
The gunmen sneaked pistols into the heavily guarded hotel by hiding them in their socks and saying they were going to dinner at the hotel, he said, adding that two hotel security guards were wounded.
Mohammad Ayub Salangi said earlier that one of the gunmen had been trapped in a bathroom by security forces.
Taliban spokesman Zabihullah Mujahid said a large number of fighters attacked the hotel and were fighting with police.
"This attack shows that our people, if they decide to attack any place they can do it," he said in an email to journalists.
The Taliban have threatened a campaign of violence to disrupt upcoming elections.