Six foreign UN employees have been killed and nine wounded in an attack in Kabul, the deadliest on the UN in Afghanistan since the Taliban's fall.
Three militants attacked a guesthouse used by the UN. They were later shot dead. Two Afghan security personnel and a civilian also died.
The Taliban said they carried out the attack, which comes 10 days before the second round of presidential elections.
Later, rockets were fired at the city's five-star Serena Hotel.
'Very dark day'
The UN condemned the "brutal" attack on the guesthouse in the Shar-i-Naw district and said it remained "committed to Afghanistan".
Andrew North, BBC News, Kabul
These attacks on two high-profile targets have spread a lot of fear.
Security preparations were getting under way to protect the vote on 7 November. There are thousands of Afghan troops in and around Kabul but determined militants are still able to get through.
The UN guesthouses have to conform to specific rules on security but we don't know how these militants were able to get through the security.
The head of the UN mission, Kai Eide, said this was a "very dark day" for the UN and that the deaths were a "loss to each and every member of the UN family here in Afghanistan".
But he added: "This attack will not, I repeat, will not deter the UN from continuing its work to reconstruct a war-torn country and to build a better future for the Afghan people."
The attack on the private Bekhtar guesthouse, which is used by the UN and other international organisations, happened just before 0600 (0130 GMT).
The US embassy has confirmed one of the dead is an American.
Taliban spokesman Zabiullah Mujahid claimed responsibility for the attack in a telephone call to the Associated Press.
He said three Taliban militants with suicide vests, grenades and machine guns had carried out the assault.
UN spokesman Aleem Siddique told the BBC there was gunfire and an explosion outside the building as UN employees tried to flee. Streets were cordoned off by police. The three gunmen were shot dead and the incident ended at about 0830 local time.
It was not immediately known how many people were inside the guesthouse at the time. The building was gutted by fire.
One foreign Kabul resident told the BBC the attack involved multiple grenades and automatic weapons.
"I saw people on the roof [security guards] and one woman climbed down from a second storey balcony after she had stood screaming and shouting for about five minutes for someone to come help her. Much of the gunfire was random - security guards shooting at nothing," he said.
KABUL YEAR OF VIOLENCE
24 Oct: Six UN staff and three Afghans killed in attack on UN guesthouse
8 Oct: Suicide bomber attacks Indian embassy, killing at least 17
17 Sept: Six Italian soldiers and 10 Afghans die in bomb attack on military convoy
18 Aug: Suicide car bomber kills 10 in attack on convoy of Western troops
11 Feb: Assault on three government buildings kills 27, including eight attackers
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.