KABUL, Afghanistan — Taliban fighters stormed a guesthouse next to the Spanish embassy in the Afghan capital on Friday, sparking an armed standoff with security forces in the upscale area popular with expatriates.

As many as four attackers were holed up inside the building — presumed wearing suicide vests ready to detonate — and were exchanging fire with Afghan special forces units, Afghan Interior Ministry spokesman Sediq Sediqqi told NBC News.

"We still do not know how many diplomats or guests might be hold up inside so we are conducting the clearing operation carefully as not to harm any civilians," Sediqqi said.

Two guards were killed and seven others were injured after the militants detonated a car bomb at the gate and stormed the building in the Shirpour neighborhood, according to a senior police official.

In addition, two attackers were killed and one was injured during the clearing operation, Afghan Deputy Interior Minister Mohammad Ayub Salangi tweeted later Friday.

A spokesman for the Spanish foreign ministry in Madrid confirmed to NBC News that its embassy in Kabul was under attack.

Members of the Afghan security services arrive at the scene of Thursday's attack. JAWAD JALALI / EPA

Taliban spokesman Zabihullah Mujahid said in tweet that "a foreign invaders' guesthouse ... came under suicide attacks this evening, heavy casualties inflicted and firefight ongoing."

Harun Arsalai, a 34-year-old Afghan freelance journalist who spends his time between Kabul and the San Francisco Bay Area, was in a restaurant a block away when the blast rocked the city.

"The explosion … shook the entire building and blew out all the glass," he told NBC News via telephone. "It blew out all the windows in the front."

After the bomb went off, "shooting erupted in the streets," he added. "We were trapped between the shooting … the firefight was all over the area … I would assume there was a lot of assailants."

Arsalai said he and around 20 others managed to escape out of the back of the building.

Shirpour serves as Kabul'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.

"Nobody wants to see violence of this sort in Kabul," Kirby said. "It does underscore the fact that Afghanistan still remains a dangerous place, and also underscores the urgency and the need for there to be continued support for President [Ashraf] Ghani, as he and Chief Executive Officer [Abdullah] Abdullah work towards an Afghan-led reconciliation process."

Alexander Smith and Milena Veselinovic reported from London.