A Taliban homicide bomber detonated his explosives as Afghanistan's deputy chief of intelligence visited a mosque east of Kabul on Wednesday, killing the Afghan official and 22 others.

The attack struck at the heart of Afghanistan's intelligence service and underscored the Taliban's increasing ability to carry off complex and targeted attacks.

The explosion ripped through a crowd in Laghman province just as officials were leaving the main mosque in Mehterlam, 60 miles east of Kabul. Two top provincial officials from Laghman were among the dead, and the blast destroyed several government vehicles.

A Taliban spokesman said a homicide bomber on foot targeted Abdullah Laghmani, the deputy chief of Afghanistan's National Directorate for Security. The spokesman for Laghman's governor, Sayed Ahmad Safi, confirmed Laghmani was killed.

The National Directorate for Security, or NDS, is headed by an ethnic Tajik, and the killing of Laghmani, a Pashtun, could further exacerbate ethnic tensions as the country counts the results of the Aug. 20 presidential election. With about half the results in, President Hamid Karzai, an ethnic Pashtun, leads Abdullah Abdullah, who is half Pashtun and half Tajik but is seen as a Tajik candidate.

The blast killed Laghmani, the executive director of Laghman's governor's office, the head of Laghman's provincial council, two of Laghmani's body guards, and 18 civilians, said Sayed Ahmad Safi, the spokesman for Laghman's governor.

U.S. troops cordoned off the blast site, right outside Mehterlam's main mosque, which sits in a crowded market area. Safi said Laghmani was visiting the mosque to discuss plans to rebuild it.

Taliban suicide attacks frequently target high-ranking government officials. Militants have warned Afghans for years not to work as government officials, teachers, or in the country's armed forces.

The Taliban is made up of ethnic Pashtuns, and the targeting of a top Pashtun security official could serve as another warning for Afghans to avoid government employment.

Taliban attacks have spiked the last three years and insurgents now control wide swaths of territory, momentum that forced President Barack Obama to send 21,000 additional troops to the country this year.

U.S. military officials may soon ask for even more troops to be sent to the country, but American public opinion is starting to turn against the almost eight-year war as U.S. troop deaths have reached an all-time high.

The National Directorate for Security suffered a second attack in the country's north. An intelligence officer kidnapped a few days ago by Taliban militants in Kunduz province was found Wednesday hanging from a tree on the outskirts of Baghlan city, said Kabi Andarabi, the provincial police chief.

In other violence, four militants were killed overnight when a roadside bomb they were planting detonated, said Fazel Ahmad Sherzad, the deputy police chief of Kandahar.