Four Taliban suicide bombers attacked the main UN compound in western Afghanistan, but there were no casualties among UN staff, police have said.
The attack with rockets, machine guns and bombers hit the UN compound in Herat, a commercial hub and the largest city in the country's west.
Two attackers, including a car bomber, blew themselves up at the entrance and another detonated his bomb just inside, while a fourth was shot and killed, police, government and UN officials said.
It was the highest-profile attack on the United Nations since last year.
'This was a complex attack with rockets, machine guns plus suicide bombers. The attack was repelled, they did not succeed,' UN envoy to Afghanistan Staffan de Mistura said.
'No UN staff were wounded,' he said.
Two Afghan police officers were reportedly wounded in the attack, he added.
At least one of the attackers was dressed in a burqa worn by many Afghan women and others were in local Afghan police uniforms.
One of Afghanistan's largest cities, with a population of about 3m, Herat is under the regional command of Italian troops and has enjoyed relative calm compared with more restive parts of the country.
Earlier this year, NATO's regional commander said districts within Herat were ready to see their security responsibility transferred to Afghan forces.