KABUL (Reuters/AFP) - Afghan security forces have killed all the insurgents involved in the attack on a guest house near the Spanish Embassy in Kabul, Interior Minister spokesman Sediq Sediqqi said.
But two Spanish security officers were killed in the attack, in a heavily protected part of Kabul close to several embassies and government buildings.
Four Afghan police were also killed, Kabul police chief Abdul Rahman Rahimi said.
"Four Afghan policemen, two foreign nationals and four attackers were killed in the terrorist attack in Kabul," Mr Fraidoon Obaidi, the head of Kabul's Criminal Investigation Department, told AFP.
The government in Madrid confirmed that the two foreigners were Spanish policemen killed during the assault.
In addition, one Spanish citizen and nine Afghan civilians were wounded and another 47 Afghans and foreigners were rescued from nearby buildings where they were trapped as security forces sealed off the area around the guest house.
The latest in a series of attacks on foreign targets in Kabul began at about 6pm local time on Friday when a suicide attacker detonated a car bomb near the guest house, allowing three gunmen to take up positions and open fire on security forces.
Security men near the embassy ducked from gunshots as they hauled away a limp body and two wounded men through the dark to a waiting ambulance - one bleeding from the head, the other a policeman with a gunshot wound to his leg - an AFP photographer saw.
Afghan officials said the last of the four assailants was killed in the early hours of Saturday.
"The operation took time because we wanted to rescue the people trapped in surrounding buildings and we had to move cautiously and in a proper tactical manner," Mr Rahimi said.
In a message posted to his Twitter account, Mr Sediqqi said all of the attackers had been killed.
The Taleban claimed responsibility for the attack, just days after President Ashraf Ghani returned from a regional peace conference in Pakistan, where he sought support to revive peace talks that stalled this year.
It followed a separate Taleban attack on the airport complex in the southern city of Kandahar, in which at least 50 civilians and security forces personnel were killed.