Taliban insurgents attacked the United States consulate in Herat in western Afghanistan early Friday morning, leaving eight people dead and several wounded.
A suicide bomber set off an explosion outside the consulate's gates shortly before dawn, a Taliban spokesman told the BBC. That allowed heavily armed attackers to breach the compound's perimeter and open fire on consulate buildings, an Afghan army official said.
Guards and Afghan security forces returned fire and within hours had secured the compound.
"The consulate is currently secured with all enemy forces being killed," NATO's International Security Assistance Force tweeted at 8 a.m.
As well as the attackers, "many Afghan civilians were killed in the attack, along with others who work for the Consulate as contractors," the US Ambassador to Afghanistan, James B. Cunningham, said in a statement. He did not give figures.
Afghan TV reported that during the resulting two-hour gunbattle, five insurgents died as did two security guards and one civilian.
As many as 18 other people were wounded, an official at Herat's main hospital said.
There were no American casualties, according to a US State Department spokesperson.
The Taliban claimed responsibility for the attack. In an emailed statement to reporters, they said it was intended to "show the Americans that they are not safe anywhere in this country."
In his statement, Ambassador Cunningham said the US government condemned the attack and thanked the Afghan and NATO forces who helped defeat it.
Extending condolences to the families of Afghans killed or injured in the assault, he said: "We are reminded again of the very real human toll exacted by terrorism. The perpetrators of this attack have shed Afghan blood on Afghan soil."
Insurgents often stage so-called "complex" attacks involving suicide bombers and fighters on targets such as Afghan government and security forces, especially in the south and east of the country, although assaults on high-profile and well-protected US targets are less common.
Exactly two years ago, insurgents attacked the main US embassy and NATO headquarters in the Afghan capital, Kabul, killing at least nine people.
Reuters contributed to this report.
More from GlobalPost: Amnesty International warns of abuses in Mogadishu forced evictions
Every day, reporters and producers at The World are hard at work bringing you human-centered news from across the globe. But we can’t do it without you. We need your support to ensure we can continue this work for another year.
Make a gift today, and you’ll help us unlock a matching gift of $67,000!