The attack, in the Qassaba district near Kabul International Airport, comes just five days after militants mounted a brazen assault on the airport, forcing an hours-long suspension of international flights to the capital.

The head of Qassaba’s crime branch, Sajda Fahal, said the attacker detonated the explosives at 6:30 a.m. while a training course was underway. Two Nepalese guards and one Philippine guard were killed. Another foreigner also was killed, but the nationality could not be confirmed. Six foreigners were injured, he said.

In a statement, the Taliban asserted responsibility for the attack, saying one of its operatives had killed 15 “foreign spies.” The Taliban, which has been waging a years-long insurgency here, often exaggerates casualty figures.

A foreign security contractor keeps watch at the site of a blast outside the counter-narcotics office near the Kabul International Airport on July 22, 2014. (Omar Sobhani/Reuters)

Interior Ministry spokesman Sediq Seddiqi said the compound also hosts a U.S. security firm, DynCorp. Two employees of the Interior Ministry’s counternarcotics unit, who spoke on the condition of anonymity because they were not authorized to talk to the news media, said their section of the compound was the target of the attack. The foreign advisers to the ministry both work and live on site and rarely leave it, employees there said.

The attacker wore a police uniform that enabled him to breach the perimeter, security officials and ministry employees said. In recent years, a number of Afghan police personnel and soldiers have carried out attacks on their foreign counterparts.

NATO troops are expected to withdraw from the country by the end of the year. But foreign advisers and analysts have concerned that Afghan forces are ill-prepared to take on Taliban militants, who have such a wide reach across the country.