Media playback is unsupported on your device Media caption Quentin Sommerville in Kabul describes the eight hour long attack

Militants have attacked the traffic police headquarters in the Afghan capital, Kabul, taking control of the building for several hours.

At least three policemen and five insurgents were killed during the battle to regain control.

The Taliban claimed responsibility for the attack, which began when a suicide bomb was detonated shortly before dawn.

It is the second such major attack in Kabul in a week.

Last week, the National Directorate of Security, in the city centre, was attacked, and four guards working for the intelligence services were killed.

Hand grenades

Monday's siege began when two bombs were detonated - one a suicide bomb and the second a car bomb - before armed men stormed the building in the west of the capital.

It took Afghan forces nine hours to dislodge them, Interior Ministry spokesman Sediq Sediqi told the Associated Press.

Kabul police chief Gen Ayoub Salangi told Agence France-Presse that the operation had taken a long time partly because police did not want to damage documents held inside the building.

"It's over. The last two terrorists are dead and they were not even given the chance to detonate their suicide vests," he said.

The militants were armed with heavy machine guns and rocket-propelled grenades and tossed hand grenades out of windows of the four-storey building.

During the siege, explosions could be heard across the city and black smoke could be seen rising from the upper floors of the building.

Earlier, Gen Salangi told the BBC that four police and six civilians had been wounded in the attack.

The strategic location of the traffic department - close to several key police units as well as the country's parliament - suggests it could have been chosen as a launching pad for a more prolonged attack, the BBC's Bilal Sarwary in Kabul says.

The incident caused traffic gridlock in certain areas of Kabul - where busy intersections are controlled by police rather than traffic lights - as officers were unable to get to work.

Militant groups continue to mount regular attacks in Afghanistan, raising questions as to how the Afghan security forces will cope after international troops leave the country in 2014.

On Monday, Afghans took to Twitter and Facebook to criticise the security services for their inability to prevent such audacious insurgent attacks.