An Afghan police guard was killed on Friday when a UN compound in the western city of Herat was attacked, officials said, as fighting raged between government forces and the Taliban.
Violence has surged across Afghanistan since May, when the Taliban launched an offensive and US-led foreign forces began their withdrawal.
The militants seized dozens of districts. In Herat province, they have captured two border crossings into Iran and Turkmenistan.
Unconfirmed local reports say the Afghan army has been supported by US air strikes around Herat, although the fledgling Afghan air force is known to be active over the battlefield and the US issued no statement about whether it was involved in the battle.
On Friday, the fighting in Herat city forced dozens of families to flee, residents said, as the insurgents advanced.
The UN's main compound was hit by rocket-propelled grenades and gunfire, a statement issued by the United Nations Assistance Mission in Afghanistan (Unama) said.
"This attack is deplorable and we condemn it in the strongest terms," said Deborah Lyons, the UN Secretary General's special representative for Afghanistan.
"The perpetrators of this attack must be identified and brought to account."
Unama said the attack was carried out by "anti-government elements".
But it said the area was the scene of heavy fighting between the Taliban and government forces.
The US said it "strongly condemned" the attack.
"The United Nations in Afghanistan is a civilian entity focused on supporting peace efforts, promoting the rights of all Afghans and providing humanitarian and development assistance," said National Security Adviser Jake Sullivan, urging the Afghan government and Taliban to resume peace talks.
UN Secretary General Antonio Guterres repeated the UN's "commitment to support the government and people of Afghanistan in their efforts to achieve peace and stability".
Concern for diplomatic missions
The Taliban said they would not single out foreign diplomats, but they have breached international protocol.
When the hardliners seized control of Kabul in 1996, they entered the UN compound and abducted the country's former leader, Najibullah Ahmadzai, who was tortured and murdered.
Two years later, after they established control over much of Afghanistan, Taliban fighters entered the Iranian consulate grounds in Mazar-i-Sharif and killed 10 diplomats and a journalist with the state news agency.
The EU delegation to Kabul blamed the Taliban for the attack on the UN compound in Herat.
"The Taliban have to account for the crime which will be considered an attack against all of us. It is contrary to all assurances given," ambassador Andreas Von Brandt, head of the EU delegation, wrote on Twitter.
For two days, the insurgents and government forces have clashed on the outskirts of Herat, Afghanistan's third-largest city, with 600,000 inhabitants.
AFP reported that the Taliban and Afghan forces were also fighting on the road leading to the city airport on Friday, while residents reported clashes in the districts of Injil and Guzara.
"People there are terrified," said Abdul Ansari, who fled to the city from Guzara.
"The fighting is heavy but they have not captured the district of Guzara so far," said Mohammad Allahyar, who also sought shelter in Herat.
Afghan forces and militiamen of veteran warlord and anti-Taliban commander Ismail Khan were reported around the city in recent days.
Mr Khan, who fought the Soviet occupation forces in the 1980s and the Taliban in the 1990s, has vowed to fight the insurgents again.
Fighting has also raged in the southern provinces of Helmand and Kandahar since Thursday.
In Helmand, the Taliban attacked the provincial capital of Lashkar Gah from several directions on Thursday, police officer Daud Shah said.
He said the insurgents fired on police checkpoints but were repelled by strikes carried out by the Afghan Air Force.
At least 33 people were wounded in fighting in the past 24 hours across Kandahar province, hospital authorities said.
In a tweet, Unama expressed concerns around "escalating violence" in and around Kandahar city, and said there were "credible reports of civilians killed".