It was the worst attack on the UN in the country since the rout of the Taliban in 2001, and an attempt to destabilise the second round of presidential elections which take place next week.
Four men and a woman leapt from second-storey balconies as fire en-gulfed the UN compound. An American man said he held off the assailants with a Kalashnikov until guests could escape.
A volley of rockets also landed in the grounds of the city's five-star Serena hotel, which is used by foreigners, and is close to the presidential palace. Hundreds of hotel guests were evacuated into underground bunkers.
The Taliban claimed responsibility, warning the attack was the start of a campaign to disrupt next Saturday's presidential run-off, called after UN-backed auditors found widespread fraud in the votes received by President Hamid Karzai in August's first-round poll. He will run against his main challenger Abdullah Abdullah.
A former British soldier who was nearby said: "It sounded like a well-disciplined, well-organised attack. There was a grenade and then a lull, as if they had already taken control."
The UN has been pivotal in supporting the elections. Some of the staff caught in today's attack were thought to have arrived in Kabul to help prepare for the second round of voting.