KABUL -- An audacious Taliban attack on a Kabul guesthouse that left 14 people dead, including nine foreigners, underscores the difficulties President Ashraf Ghani faces in providing even basic security following the withdrawal of international combat troops from Afghanistan.

The hourslong siege, which ended early Thursday, was the deadliest in Kabul since the insurgents launched their annual "spring offensive" against Ghani's administration in late April, sparking fierce battles that have forced the government to concentrate resources on security at the expense of desperately needed reforms.

An American, a British citizen, an Italian, four Indian nationals and two Pakistanis were among the dead. Five Afghans were also killed and seven were wounded, including a policeman.

By targeting a guesthouse popular with international residents and visitors, the Taliban also stoked fears they were renewing their strategy of killing foreigners, which will further undermine Ghani's credibility in his efforts to bring peace, stability and prosperity not only to Afghanistan but to the broader region.

"The attack shows that Kabul is very vulnerable. An increase in attacks on Kabul can paralyze life here, and if there is a cascade of attacks in Kabul, it can hurt the government," said Haroun Mir, an independent political analyst.

Gunmen stormed the Park Palace Hotel in downtown Kabul as guests gathered Wednesday evening for a concert by a popular Afghan musician attended by an audience that included diplomats, business people, charity workers, academics and others.

As gunfire echoed around the guesthouse in the Shar-i-Naw neighbourhood -- near United Nations compounds and a foreign-run hospital -- the area was rapidly surrounded by heavily armed police and special forces in armoured Humvees.

Some 60 people were held hostage until the early hours of Thursday morning. Sporadic gunfire and a series of muffled explosions were heard over about five hours, before Kabul police chief Gen. Adbul Rahman Rahimi announced the siege was over. Firefighters quickly moved in to clear the building, which was cordoned off as residents moved out.

The Taliban claimed responsibility in an emailed statement that said the hotel was targeted because of the presence of foreigners, including Americans. Spokesman Zabihullah Mujahid said it was carried out by a lone attacker armed with a Kalashnikov rifle, a suicide vest and a pistol. However, authorities in Kabul said three gunmen were involved and all were killed in the shootout with Afghan security forces.

Ghani condemned the attack and lashed out at the Taliban in a statement Thursday, vowing the insurgents would not derail his plans to bring peace to his war-ravaged nation. He said he had spoken to the leaders of the nations whose citizens were killed, adding: "The terrorists and enemies of Afghanistan cannot harm our country's relationships with other countries with these activities."

Since taking office in September, public support for Ghani has rapidly evaporated, along with faith in his promises to bring reform and peace. His cabinet still lacks a defence minister and plans to kick-start a moribund economy, creating much-needed jobs after the withdrawal late last year of foreign combat forces and many non-government organizations, have stalled.

In the months immediately after his inauguration, Ghani embarked on a diplomatic offensive aimed at winning the support of neighbouring nations for his vision of transforming Afghanistan from a war-torn no-go zone into a hub for regional economic co-operation. Central to his plan was drawing the Taliban into a dialogue that would eventually lead to peace talks and its possible inclusion in government.

Earlier this month, representatives of Ghani's government and the Taliban met informally in the Gulf state of Qatar. During discussions there, both sides emphasized that peace talks were not on the agenda. Nevertheless, the Taliban issued a statement that implied a new flexibility on previously intractable issues, such as the presence of foreigners in Afghanistan and acceptance of a constitution.

At the same, violence continues to escalate.

The U.N. mission in Afghanistan condemned Wednesday's assault as an "atrocity," and said it had documented a record high number of civilian casualties -- 974 killed and 1,963 injured -- in the first four months of 2015, a 16 per cent increase over the same period last year.

"Taliban statements on avoiding civilian casualties ring hollow when we set them against the latest killings," the mission's human rights director, Georgette Gagnon, said in a statement.

The attack also shows how the Taliban have been able to adapt to the tightened security situation in the Afghan capital, where smuggling in large amounts of weaponry has become increasingly difficult.

"Everyone had been expecting a big Taliban attack on Kabul to mark the launch of the spring offensive, something like a truck bomb, but that didn't happen," said a diplomat who spoke on condition of anonymity because he was not authorized to talk to the media. "So they come with smaller weapons and firearms."

At the same time, the Taliban has used the government's preoccupation with internal machinations, including disputes between Ghani and chief executive Abdullah Abdullah over cabinet appointees, to formulate a strategy aimed at crippling plans for reform, said Mir, the analyst.

That strategy "is now rolling out across the country, with attacks across the east and north -- we don't know what they will do from one day to the next," Mir said.

"The Taliban know that the government coffers are empty. Any attack will force the government to spend on security. The government is not yet fine-tuned and it needs to be fine-tuned to function properly," he said. "This strategy of insurgency undermines its ability to fine-tune. Its focus has to be on security. It can't do anything else."

Associated Press writer Amir Shah in Kabul, Afghanistan, contributed to this report.