Two Taliban suicide bombers blew themselves up at a Kabul police HQ before another group stormed the compound in a nine-hour battle that left three officers and all five attackers dead.
The coordinated assault was the second raid in the heart of the Afghan capital in less than a week, a sign that the insurgency is determined to keep carrying out spectacular attacks even as the US and Afghan governments try to coax the Taliban into holding peace talks.
Nine hours after the attack began, police commandos killed the last two insurgents holed up in the headquarters.
Kabul Police chief Mohammad Ayub Salangi said two Taliban died at the gate when their suicide vests exploded, another blew himself up inside the building and two more were killed by security forces before they managed to detonate their explosives.
He said a car packed with explosives blew up near the gate a short time later. Such secondary devices are rigged to timers and designed to kill as many rescuers as possible.
The Taliban claimed responsibility for the attack, which they said was targeting a police training facility "run by foreign military forces."
The traffic police headquarters is not heavily guarded, although it is on a square leading to parliament. It is also adjacent to the Afghan border police headquarters and a police training facility - which may have been the more likely target. The traffic police facility, usually teeming with civilians seeking to get driving licences and registrations for vehicles, was nearly empty at the time of the attack.
Last Wednesday six Taliban suicide bombers attacked the gates of the Afghan intelligence agency in Kabul, killing one guard and wounding dozens. That operation bore several similarities to the latest attack, including the use of a secondary car bomb outside the compound.
The attacks came as the Afghan government has been pushing to get the Taliban to the negotiating table and as president Hamid Karzai and the US negotiate for a quicker pullout of American forces. Barack Obama said after meeting Mr Karzai that the military coalition would hand over the lead for security around the country to Afghan forces this spring - months ahead of schedule.
Pakistan, the other regional powerbroker, also said last week that it plans to release more Afghan militant detainees in an attempt to boost the peace process ahead of the departure of international troops at the end of 2014.