KABUL — A Taliban attack and an ensuing hours-long siege at a guesthouse in Kabul's diplomatic enclave left 12 dead, including four militants, police said on Saturday.

Four Afghan police, a security guard, civilian and and two foreign nationals — including one Spanish security officer — died in the onslaught at the guesthouse, Kabul police chief Gen Abdul Rahman Rahimi told NBC News.

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 building, which guards at the site said formed part of the Spanish embassy compound.

Militants detonated an explosives-laden car at the gates of the guesthouse at around 6 p.m. Three others stormed the building and were killed after 10 hours of gunfire.

A special forces commander told NBC News that four foreigners were rescued from a safe room in the guesthouse after the standoff ended and the building at around 6:20 a.m. Saturday local time (8:50 p.m. Friday E.T.).

Related: Taliban in Armed Standoff Near Spanish Embassy in Kabul

"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.

The attack occurred in Kabul’s Shirpour neighborhood, which serves as the city’s de facto diplomatic enclave. It features several foreign embassies, non-governmental organizations, and a significant expatriate community.

U.S. State Department spokesman John Kirby said all American chief-of-mission personnel are accounted for and there are no reports of American casualties.

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 has spread since foreign forces ended combat operations last year.