KABUL, Afghanistan — The Taliban’s bloody, 14-hour siege on a major hotel in Kabul ended on Sunday, after six assailants terrorized much of the city with explosions and gunfire.

The exact number of casualties remained unclear, and the authorities said it might take days to determine the extent of the material damage. Najib Danish, a spokesman for the Interior Ministry, said that 14 foreigners and four Afghans had been killed in the attack, and that 10 others, including six members of the security forces, had been wounded. Local news outlets put the number of dead at 43.

The siege capped a violent 24 hours across Afghanistan, where about 50 people were killed in four provinces as the 16-year war continues to spiral more violently, with no tangible signs of a resolution.

A guest, Abdul Rauf, 48, said he had run through the halls of the hotel as an armed man was firing and had then taken cover in his room.

“I don’t know if he was the police or a suicide attacker, but he was shooting,” he said by cellphone while hiding under the bed of his hotel room. “Two rooms were on fire and smoke came into my room. I couldn’t breathe until I broke a window with my chair.”

The attack was the second in eight years at the 200-room Intercontinental Hotel, located on top of a hill. The Afghan carrier Kam Air said that six of its employees from Ukraine were killed, along with two from Venezuela.

The airline connects parts of the country where travel by road is increasingly impossible. It flies decrepit planes that sometimes bear the marks of their many previous lives: exit signs in Swahili; emergency instructions in Russian.

Kam Air canceled several flights on Sunday, according to Farid Peykar, the company’s vice president, who added that operations would be affected for days to come as the carrier tries to attend to the shock and concern of its staff members.

Among the dead were Afghans including Ahmad Farzan, a 34-year-old religious scholar turned peace activist. Mr. Farzan had left his three young daughters in Kandahar to come to Kabul to teach university classes and work at the country’s High Peace Council, a body exploring negotiations with the Taliban.

He often appeared as an analyst on local television, and he was critical of the difficult regional dynamics that choke any hopes of Afghan peace. But he had begun the new year with a message of hope, posting on his Facebook page:

“Life is beautiful

One day, one hour, one minute

will never return.

Then, please, stay away from violence

avoid frustrations

speak of love.”

Carnage and Confusion

The Taliban, usually quick to claim attacks, did not issue a statement declaring its responsibility for the assault on the Intercontinental Hotel until 14 hours after the siege began. At least two senior Afghan officials said the country’s intelligence agency had received reports that the Haqqani Network, a particularly brutal arm of the Taliban, had planned the attack.

“The attack was carried out by #Pakistan based Haqqani Terrorist Network,” Javid Faisal, a spokesman for the Afghan government’s chief executive, said on Twitter.

Mr. Danish, the Interior Ministry spokesman, said six assailants armed with grenades and AK-47s had entered the hotel through the kitchen around 9 p.m. on Saturday. Most of the rooms were occupied, with at least 100 guests of the Ministry of Communications and Information Technology staying there for a conference.

Helicopters and drones circled above the hotel for hours while guests hid inside, many cowering under beds or in toilet stalls. Television footage showed guests trying to climb out of windows with the help of makeshift ropes. The elite forces that arrived at the scene rescued 160 guests, including 41 foreigners.

“Our investigation teams are searching and working room by room to find out exact casualties and information,” Mr. Danish said.

Image

Security forces on Sunday near the Intercontinental Hotel in Kabul, Afghanistan, the site of a 14-hour gun battle with assailants.CreditRahmat Gul/Associated Press

There was much confusion about when the operation ended. At first, the authorities declared the siege over around 9 a.m., saying all four assailants had been killed. But a New York Times reporter at the scene continued to hear explosions and gunfire, which security officials said was part of a “clearance operation.” When the Interior Ministry later said there had actually been six assailants, it became clear that two had been missed in their initial sweep.

“We tried to proceed with caution to avoid harming guests who hid in the rooms and locked the doors against the attackers,” said Maj. Gen. Afzal Aman, commander of the Kabul Garrison, which is responsible for security in the capital.

A Barricaded City

In a room on the second floor of the hotel, Haji Saheb Nazar, 45, an employee of Afghan Telecom, spent the night huddled in a bathroom, afraid to leave. After sunrise, he spoke on his cellphone in a whisper, nearly in tears. “It’s still going on, upstairs and downstairs,” he said. “I don’t know what’s happening.”

“My family is so worried about me, and they keep calling me,” he said. “I don’t know what’s going on outside and how many of them are in the hotel. But if they are only four, why can’t police kill or arrest them?”

Mukhtar, 50, an Afghan who uses only one name, spent the night on the street outside the hotel, repeatedly calling his 24-year-old son, Zaiurahman, who works inside as a security guard. He got no answer until shortly after sunrise on Sunday.

“He said he was safe. I was really happy and cried,” Mukhtar said. “From midnight until now I’ve been waiting here, and now I just want to hug him and kiss him when he comes out.”

This is not the first time a popular hotel has been the target of an attack in a city that is increasingly barricaded, with blast walls that grow ever taller.

The Intercontinental was attacked by insurgents in 2011; 21 people were killed, including nine assailants, and many others wounded before the Afghan authorities, with substantial assistance from international military forces, managed to bring an end to the violence.

The hotel was once part of the chain of Intercontinental Hotels, but is now government owned.

Other hotels have also been targeted. The Serena Hotel, a luxury establishment in Kabul, has been struck three times, including an attack in 2014 that killed nine. In that assault, Taliban gunmen hid small pistols in the soles of their shoes to evade heavy security, then entered the restaurant and killed guests at close range, including a well-known Afghan journalist, his wife and all but one of his children. The events led to an unusual apology for what the Taliban called a “mistake.”

In 2015, the Park Palace hotel in downtown Kabul was the site of an attack that killed at least 15 people, including one American.

Increasing Violence

The latest Kabul attack comes amid intensifying violence around the country. In the northern province of Balkh, which has been at the center of a recent political showdown with the central government, at least 18 people were killed in an attack by the Taliban late Saturday, most of them members of a local police militia, officials there said.

Nazar Gul Sholgarai, a commander of the local militia, said the men had been lured to a dinner reception where a Taliban infiltrator had paved the way for the attack. He said a delegation had returned with samples of the meat served at the dinner to see if the men had been poisoned before they were shot.

“The bodies are still lying there, we haven’t buried them — we are chasing after the Taliban footsteps,” Mr. Sholgarai said. “The Taliban had come on six horses and four donkeys.”

Separately, in the western province of Herat, a Toyota Corolla carrying laborers struck a roadside bomb, leaving at least eight dead, said Abdul Ahad Walizada, a spokesman for the province’s police.

In the neighboring province of Farah, the Taliban have been tightening their presence around the provincial capital, Farah City, for weeks. The group has repeatedly staged attacks on the margins of the city, where militants’ efforts to advance are often deterred by airstrikes.

The security forces have suffered heavy casualties in the province over the past month, according to members of the provincial council. Late Saturday, a Taliban roadside bomb killed Col. Gulbahar Mujahid, the province’s deputy police chief, and wounded two of his officers as they were traveling in Humvees during an operation.

“The fighting was inside Farah City and it continued the whole night, which make us stay awake and terrified,” said Abdul Rahman, a resident of Farah City. “We thought the Taliban would be all around in the city in the morning, but we found security forces around. The bazaar is not functioning due to last night’s fighting and heavy security presence in the city.”

Reporting was contributed by Fahim Abed and Jawad Sukhanyar from Kabul; Najim Rahim from Mazar-i-Sharif, Afghanistan; Taimoor Shah from Kandahar, Afghanistan; Rod Nordland from London; and Andrew Kramer from Moscow.

A version of this article appears in print on , on Page A1 of the New York edition with the headline: Extended Siege on Afghan Hotel Caps Violent 24 Hours in Region. Order Reprints | Today’s Paper | Subscribe