Taliban fighters have detonated car bombs at the US consulate in western Afghanistan, triggering a firefight with security forces in an attack that killed at least 19 people, including two Afghan members of the security forces.
At least 17 others were injured in Friday's attack, which happened in the city of Herat.
The US said its personnel from the mission were safe and that most of them were temporarily relocated to Kabul, while American forces secured the site.
According to General Rahmatullah Safi, Herat province's chief of police, the attack began when armed men in an four-wheel drive and a van set off their explosives-laden vehicles while others on foot fired on Afghan security forces guarding the compound.
Loud explosions followed by gunfire were heard and a plume of thick smoke was seen rising over the city.
Local officials told Al Jazeera that six security guards, two policemen and two interpreters were among the dead. At least nine attackers were also killed, either by police or when they detonated bombs.
Taliban spokesman Qari Yousef Ahmadi took responsibility for the Herat attack in a phone call with the Associated Press.
NATO's ISAF force later said on Twitter that it had secured the consulate and security forces had defeated the attackers.
Robert Hilton, a spokesman for the US Embassy in Kabul, said that "all consulate personnel are safe and accounted for".
The Afghan Foreign Ministry said the attack "illustrates both the desperation of the enemies of Afghanistan and their heinous, wanton disregard for the lives of Afghanistan's peace-loving citizens."
Herat, on the border with Iran, has been relatively peaceful since the removal of the Taliban by US-led forces in 2001.