The Islamic State group claimed on Monday responsibility for an attack on a hotel in central Kabul popular with Chinese nationals, the group said on its channel on Telegram.
Armed men opened fire on Monday inside the hotel, and at least three gunmen were killed by security forces.
Kabul's Emergency Hospital, run by an Italian non-profit, reported receiving 21 casualties - 18 injured and three dead on arrival.
Taliban sources said the attack was carried out at Longan Hotel where Chinese and other foreigners usually stay.
Videos posted on Twitter by a journalist in Kabul and verified by Reuters showed smoke billowing out of one of the floors amid sounds of gunshots, while a person was seen trying to escape the attack by jumping out of a hotel window.
Kabul police spokesman Khalid Zadran said the attack took place around 2.30 p.m. local time, with residents in the area saying they heard a powerful explosion followed by gunfire.
The attack came a day after China's ambassador met the Afghan deputy foreign minister to discuss security-related matters and sought more attention on the protection of its embassy.
China's state-run Xinhua news agency said the attack happened near a Chinese guesthouse and its embassy in Kabul was closely monitoring the situation.
The embassy did not respond to a Reuters request for comment.
Several bombings have taken place in Afghanistan in recent months, including an attack on the Pakistan embassy earlier this month and a suicide blast near the Russian embassy in September. Both attacks were claimed by the Islamic State.
The Taliban, which seized power after US-led foreign forces withdrew in August 2021, have said they are focused on securing the country.
(FRANCE 24 with Reuters)