A senior adviser to Afghan President Hamid Karzai and a member of parliament were killed Sunday night in Kabul, dealing a blow to an administration still reeling from last week’s assassination of Ahmed Wali Karzai, the president’s half brother.

The attack took place in the apartment of Jan Mohammad, a Karzai adviser and former governor of Uruzgan province, according to an Afghan security official who spoke on the condition of anonymity.

Three gunmen wearing explosives killed Mohammad and Hashem Watanwal, a parliament member and Karzai ally from Uruzgan. Several security guards were also killed, according to the official, who did not say whether the men were shot or killed in an explosion.

The Taliban, through spokesman Zabiullah Mujahid, quickly asserted responsibility for the attack. “We’ve been following Jan Mohammed for a long time to carry out such an attack,” Mujahid said.

Local Afghan television stations reported that one of the attackers was killed when his explosives detonated and that the other two traded fire with Afghan security officials from the apartment in the western Kabul district of Karti Char.

As of 10:30 p.m., three hours after gunmen entered the apartment, gunfire was still being exchanged, according to Ashmat Stanekzai, a spokesman for the Kabul police chief.

The killing of two trusted Karzai allies comes on the heels of two particularly devastating attacks — the assassination of Ahmed Wali Karzai by a confidant and a suicide bombing at his memorial service that killed four people.

Both incidents underscore the vulnerability of Afghan officials as the United States works to transfer security responsibilities to the Afghans.

Sunday morning, U.S. officials formally handed over security responsibility in peaceful Bamian province to Afghan officials, the first transition of its kind in the country. Afghan forces will take control of six more areas in the next two weeks.

The transition to Afghan-led security is seen as a key step in the withdrawal of NATO troops by 2014, but there are doubts about the capacity of Afghan forces. In recent months, men wearing Afghan army and police uniforms have carried out a string of attacks on U.S. troops.

Sunday’s attack appeared to further demonstrate the intensity of the campaign to take out government loyalists.

Special correspondents Sayed Salahuddin and Javed Hamdard contributed to this report.