The main UN compound in the capital of the western Afghan province of Herat was attacked by "anti-government elements" on Friday and at least one security guard was killed, the United Nations Assistance Mission in Afghanistan (UNAMA) said.
The attack, involving rocket-propelled grenades and gunfire, happened hours after Taliban fighters penetrated deep into Herat city, and heavy clashes with Afghan security forces were going on near the UNAMA provincial headquarters, officials said.
In a statement following the attack, the United Nations said it was urgently seeking to establish a full picture about the assault and was in contact with the relevant parties.
It was not immediately clear who attacked the compound, but a western security official told Reuters all diplomatic compounds in the city were put on high alert.
UNAMA said the attack was against the entrances of the compound that were clearly marked as a United Nations facility.
"This attack against the United Nations is deplorable and we condemn it in the strongest terms," said Deborah Lyons, the UN Secretary-General's Special Representative for Afghanistan.
UNAMA said no UN personnel were hurt in the incident.
Herat city is the second provincial capital the Taliban have entered in the last 24 hours. Insurgents entered the capital of the southern province of Helmand a day earlier, and clashes are under way there. Civilians rushed to evacuate the city.
"Since Thursday morning the Taliban have launched attacks from several directions on Lashkargah city," a government official told Reuters on the condition of anonymity. Lashkargah is the capital of Helmand, a southern province bordering Pakistan.
With US-led foreign forces nearing a complete withdrawal of troops, the Taliban have made swift territorial gains over the last two months but have not yet captured any provincial capitals.
A United Nations report this week said civilian casualties had been surging in recent weeks in Afghanistan, with as many killed in May and June as in the previous four months. The report did not cover casualties in July, when fighting has intensified further.