An Afghan member of parliament was killed by a bomb planted near his residence in the capital Kabul, the interior ministry has said.

The device, hidden in a electrical box attached to a wall, exploded as Shir Wali Wardak left his house, ministry spokesman Sediq Sediqqi said on Sunday.

"It could either have been a bomb on a timer or one that was remotely detonated," Sediqqi said, adding that 11 people, including five of Wardak's bodyguards, were wounded in the blast.

No group immediately claimed responsibility.

READ MORE: Civilians caught in crossfire of war against Taliban

The attack came hours after Taliban fighters stormed a courthouse south of Kabul, killing at least seven people, including a newly appointed chief prosecutor.

At least 21 other people were wounded in the attack in Puli Alim, the capital of southeastern Logar province, the head of security for provincial police force said.

"The new head of the court was being introduced today and the assailants used the rush hour opportunity to attack the court," Nesar Ahmad Abdul Rahimzai said.

He added that all three assailants were killed by Afghan security forces.

READ MORE: Afghan Taliban in deadly bus attacks

The Taliban claimed responsibility for the attack in Puli Alim. The group frequently targets government officials, and has taken aim at the judiciary since the government executed six of its members last month.

Sunday's attack is the third such attack on court facilities since the group's members were executed.

At least 10 people were killed and four others were injured when a suicide bomber hit a bus carrying judiciary staff members from Kabul to central Wardak province in late May.