Afghan security forces have ended a siege by the Taliban group of a guesthouse attached to the Spanish embassy in Kabul, after hours of intermittent gunfire and explosions.

Spain announced on Saturday the death of a second Spanish policeman in the attack, which also killed four members of the Afghan police, one Afghan civilian and four Taliban fighters.

The attack began at about 6pm (13:30 GMT) on Friday in a heavily protected part of Kabul, when a suicide attacker detonated a car bomb near the guesthouse, allowing three attackers to take up positions and open fire on security forces.

In addition, nine Afghan civilians were wounded and another 47 Afghans and foreigners rescued from nearby buildings where they were trapped as security forces sealed off the area around the guesthouse, which guards at the site said formed part of the Spanish embassy compound.

INSIDE STORY: Has US foreign policy failed in Afghanistan and Iraq?

"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," Abdul Rahman Rahimi, Kabul police chief, told Reuters news agency.

The Taliban claimed responsibility for the attack on the "invader's guesthouse", 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.

Friday's attack followed a separate Taliban attack on the airport complex in the southern city of Kandahar, in which at least 70 civilians and security personnel were killed.

The Taliban claimed responsibility for the attack on an "invader's guesthouse" which led to the deaths of soldiers and civilians [AP]

Ghani's government has come under increasing pressure as the Taliban insurgency has spread since foreign forces ended combat operations 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 issued on Saturday, the Taliban taunted authorities with the "disgrace" of not being able to prevent an attack in the heart of Kabul.

READ MORE: Afghan intelligence chief quits over Pakistan ties

"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," Zabiullah Mujahid, the Taliban spokesman, said in a statement.

The Taliban has been wracked by internal power struggles of its own, with rival factions battling for supremacy since it confirmed in July that its founder, Mullah Mohammad Omar, had died more than two years ago.

However, that has not prevented the Taliban from notching up a string of successes, including the brief seizure of the northern city of Kunduz in September.


Source: Al Jazeera and agencies