KABUL -- Attackers entered the Spanish Embassy in Kabul after a deadly car bombing in a diplomatic neighbourhood of the Afghan capital, engaging in an hour-long shootout with security forces while staff hid in bunkers, the Spanish government said Saturday in an account of the attack a day earlier.

Sediq Sediqqi, spokesman for the Afghan Interior Ministry, said four Afghan police officers and two others, including a foreigner, were killed in the attack that was claimed by the Taliban. Authorities in Madrid said two Spanish police officers were killed. The discrepancy could not immediately be clarified.

According to a statement issued Saturday by Spanish Prime Minister Mariano Rajoy's office, a powerful car bomb exploded Friday evening near the embassy, "causing serious damage to the premises" and killing Deputy-Inspector Jorge Garcia Tudela and Isidro Gabino Sanmartin Hernandez who were guarding the compound.

An hour-long shootout followed, the statement said. During the gun battle, three attackers entered the embassy compound while staff hid in two bunkers. They were released unharmed "after an intervention by Afghan and United States special forces units that lasted several hours," the statement said.

"All details of the attack are under investigation, although a statement by the attackers said that the embassy was not the intended target of their attack," the Spanish government said.

The incident caused confusion in Spain, as Rajoy initially insisted to television audiences during an election rally that the embassy had not come under attack.

Shortly after, Rajoy told reporters the only Spaniard hurt was a slightly wounded police officer who had been taken to a hospital but was expected to recover. He later acknowledged a policeman died, and hours afterward the government announced the death of the second officer.

Seven civilians and two policemen were wounded, Sediqqi said, adding that 12 foreign citizens were rescued by Afghan forces.

Zabihullah Mujahid, spokesman for the Taliban, claimed responsibility for the attack in an email sent to media outlets.

The attack took place in the Kabul district of Shir Pur, home to many foreign embassies, guesthouses and the homes of high-ranking government officials. It took local security forces more than 10 hours to bring the area back under control.

The Kabul attack came two days after another massive Taliban attack on the main airport in the southern city of Kandahar, which lasted more than 24 hours and killed more than 50 people. The casualties from the Kandahar attack, which ended Wednesday night, included 38 civilians, 10 Afghan soldiers and two police officers, according to the Ministry of Defence.

Separately, a district chief was shot and killed by insurgents in the northern province of Baghlan, said Jawed Basharat, spokesman for the provincial police chief.

Abdul Jabar, chief of the Borka district, came under attack on the main road near Puli Khumri, the provincial capital. Basharat said that Jabar's driver and two of his bodyguards were abducted by the insurgents and police forces were searching for them.

No group has yet claimed responsibility for killing Jabar, but Taliban militants have increased their attacks recently on Afghan government officials and security forces.

Heckle reported from Madrid. Associated Press writer Cristina Fuentes in Madrid contributed to this report.