Afghan security forces suppressed a suicide attack on a guest house attached to the Spanish embassy in Kabul, killing three Taliban fighters after hours of intermittent gunfire and explosions that lasted into the early hours of Saturday.
Two Spanish security officers and four Afghan police were also killed in the attack, in a heavily protected part of Kabul close to several embassies and government buildings, Kabul police spokesman Basir Mujahid said.
In Madrid, the Spanish government said all other embassy staff had been evacuated from the site and were receiving treatment.
More From This Section
The latest in a series of attacks on foreign targets in Kabul began at about 6 pm 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.
"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," Kabul police chief Abdul Rahman Rahimi told Reuters after the operation ended at around 5.30 am.
The Taliban claimed responsibility for the attack on the "invader's guest house", 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.
Ghani's government has come under increasing pressure as the Taliban insurgency, aimed at expelling foreign forces and bringing down the Western-backed government, has spread since NATO ended its combat mission last year.
The head of the intelligence services, who strongly opposed Ghani's bid to involve Pakistan in the peace process, resigned on Thursday, underlining divisions in the national security apparatus.
In a statement, the Taliban taunted authorities with the "shame and humiliation" of not being able to prevent an attack in the heart of the capital.
"The presence of our Mujahideen with weapons and a car loaded with explosives in such a high security area shows God's support and the cooperation of the poor and Muslim people," spokesman Zabihulla Mujahid said.
China calls for better intelligence on terrorism
China needs to improve its intelligence gathering abilities and intelligence sharing between different departments it if wants to better deal with the threat of terrorism, its domestic security chief said, in a rare admission of the problems faced.
Hundreds of people have been killed in the past few years in China's western region of Xinjiang, home to the mainly Muslim Uighur people, in violence blamed by the government on Islamist militants who want to establish an independent state called East Turkestan.
Speaking in Xinjiang's regional capital Urumqi, domestic security chief Meng Jianzhu said while some success had been achieved in the fight against terrorism, the situation remained serious.
Meng said intelligence gathering had to improve, in both what he called "hard and soft intelligence."
"Push the joining up and deeper integration of both the national and Xinjiang anti-terrorism intelligence platforms, put into effect the sharing of information," the statement paraphrased Meng as saying.