A marathon deadly siege on a major hotel in Afghanistan's capital, Kabul, has ended with the killing of all gunmen who fought off security forces for 16 hours.

The Taliban claimed responsibility for the attack on the heavily-guarded Intercontinental Hotel in the Bagh-e Bala which left at least 18 civilians dead and 22 wounded.

Dressed in army uniforms and armed with automatic weapons, the attackers stormed the building on Saturday evening.

The assault sparked dramatic scenes, captured by Afghan news channels, as guests climbed down bedsheets tied to balconies to escape, with some losing grip and falling to the ground.

Special forces rushed into the scene to fight the attackers, in a gun battle that continued well into Sunday.

Najib Danish, spokesman for the Afghan interior ministry, told Al Jazeera that four Afghan civilians and 14 foreigners were among those killed. Four attackers were also killed.

Afghan airline company Kam Air said in a statement that some of their employees had been killed and wounded in the attack. The company used the hotel to accommodate its staff.

The Ukrainian Foreign Ministry said on Twitter that an Ukrainian national was among the dead.

Omar Zakhelwal, Afghanistan's ambassador to Pakistan, told Al Jazeera the Afghan counsel general in Pakistan's Karachi had been killed in the attack.

We know the fighting went room-to-room, we know that many guests spent terrifying hours overnight hiding in their rooms as the gunmen moved through the hotel.

"Officials are inside [the hotel] now to conduct their investigations and to assess whether they will find any more casualties," Al Jazeera's Jennifer Glasse, reporting from Kabul, said.

"We know the fighting went room-to-room, we know that many guests spent terrifying hours overnight hiding in their rooms as the gunmen moved through the hotel."

A Taliban spokesperson claimed responsibility for the attack, saying it was carried out by five of its members.

"Our five fighters, Bilal, Ayubi, Khalil, Bashar and Abid entered the building and conducted the operation that resulted in the death of 10 foreigners and Afghan government officials," Zabihullah Mujahid, the Taliban spokesperson, told Al Jazeera.

The Afghan government, however, said the attack had been carried out by four attackers.

"We recovered the bodies of at least four attackers," said Danish.

A witness, Abdulhaq Karimi, told Al Jazeera that several bodies of security guards could be seen close to the gate of the hotel.

The interior ministry said a private firm had assumed responsibility for the security of the hotel around three weeks prior to the attack.

Authorities launched an investigation to find out how the attackers had managed to enter the heavily-protected building that is frequented by government officials and foreigners.

"The fighters can manage to attack anywhere they like. Nowhere is safe," said Karimi, the eye witness.

The attack came days after the US embassy in Kabul had issued a warning that armed groups may be planning attacks against hotels in the city.

This was the second time the Intercontinental hotel came under attack.

In 2011, an overnight assault by Taliban fighters and suicide bombers on the hotel ended with security forces killing the attackers and the deaths of at least 10 civilians.

The siege was just one of several attacks on Sunday.

In a village in the northern province of Balkh, Taliban fighters raided houses in the middle of the night, pulling police officers from their homes and shooting them dead.

At least 18 officers were killed, deputy police chief Abdul Raziq Qaderi told local reporters.

In western Herat province, at least eight civilians were killed when a car hit a Taliban-planted roadside mine, officials said.