KABUL/ PUL-I-ALAM - An Afghan member of parliament was killed by a bomb planted near his residence in the capital Kabul on Sunday, the interior ministry said.

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

"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.

The attack came hours after Taliban insurgents stormed a courthouse south of Kabul, killing at least seven people including a newly appointed appeals court head.

Taliban gunmen stormed the court complex in Pul-i-Alam, killing at least seven people in the insurgents' third so-called "revenge" attack for last month's execution of Taliban-linked prisoners.

The attack in Pul-i-Alam, capital of volatile Logar province, also left 23 prosecutors wounded as they were meeting to decide the fate of six newly arrested Taliban militants.

The head of the court Mohammad Akram Nejat was among those killed in the attack, which comes as the Taliban step up their annual spring offensive after naming a new leader late last month.

"Three gunmen wearing police uniform entered the court building and started shooting people," the provincial governor Mohammad Halim Fedayee told AFP.

"Unfortunately seven people were killed, including Mohammad Akram Nejat, the newly appointed head of the court."

Hasib Stanakzai, a member of Logar's provincial council, confirmed the death toll.

The Taliban said the attack was in retaliation for the execution of six Taliban-linked inmates in early May, part of President Ashraf Ghani's new hardline policy against the insurgents.

"The martyrdom attack was carried out in revenge for the execution of our mujahideen," Taliban spokesman Zabihullah Mujahid said on Twitter.

The UN Assistance Mission in Afghanistan (UNAMA) was quick to condemn the attack.

The head of the mission, Nicholas Haysom urged Afghan authorities "to do everything in their power to ensure adequate protection of judicial officials and other civilians seeking access to judicial institutions".

"Judicial officials and other civilians can never be considered combatants and thus should not be targeted," he said in a statement.