One of the attackers drove a car packed with explosives into the gates of the building, allowing at least three other militants wearing explosives vests and carrying guns to enter the compound.
A spokesman for the United Nations Assistance Mission in Afghanistan, Dan McNorton, says there were no U.N. casualties from Saturday's attack.
It was not immediately clear if any Afghan guards were injured in the attack.
At least three militants -- all wearing explosives vests -- went inside after the explosion, said Nabiq Arleen, a spokesman for the provincial governor of Herat province.
Afghan security forces exchanged gunfire with the attackers, killing at least one of them, said Ministry of Interior spokesman Zemeri Bashary.
NATO troops joined Afghan forces in surrounding the site. Helicopters flew overhead.
In the south, a photographer for The New York Times was seriously injured by a mine Saturday in Kandahar province where international forces are pushing into Taliban strongholds to try to turn the tide of the war.
Joao Silva, 44, received leg injuries when he stepped on the mine while accompanying American soldiers on patrol in the Arghandab district. Silva was evacuated to Kandahar Air Field where he was receiving treatment, the newspaper said in a statement.
No U.S. troops were wounded in the morning explosion.
A group of minesweepers and bomb-sniffing dogs had just moved over the area and were several steps ahead of Silva when the bomb went off. Homemade bombs and mines cause the majority of deaths and injuries among U.S. and NATO forces in Afghanistan. Bombs made with small amounts of metal are difficult to detect.
Silva and a New York Times reporter were embedded with a unit of the 101st Airborne Division.
Silva, who has received several awards for his work, has photographed wars in Afghanistan, Iraq, southern Africa, the Balkans and the Middle East. He is the author, with Greg Marinovich, of "The Bang-Bang Club," a chronicle of a group of four photographers covering the violence in South Africa in the 1990s. The other two were Kevin Carter and Ken Oosterbroek.
"Joao is the state-of-the-art war photographer, fearless but careful, with an amazing eye," said Bill Keller, executive editor of The Times. "We're all waiting anxiously and praying for his quick recovery."
In August 2009, CBS Radio News correspondent Cami McCormick was seriously injured when the Army vehicle in which she was riding struck a bomb south of Kabul. That same month, two journalists for The Associated Press -- photographer Emilio Morenatti and videographer Andi Jatmiko -- were wounded along with two U.S. soldiers by a bomb -- also in Kandahar province.