A suspected suicide bomber has targeted the Supreme Court building in the Afghan capital, Kabul, killing at least 20 people, according to officials.

Ismail Kawasi, the public health ministry spokesman, said 41 people were also wounded in Tuesday's explosion, which hit near a side door used for court employees to leave the building at the end of the work day.

The attacker was on foot and detonated his suicide vest packed with explosives near the employees and other people as they were coming out of the main court building, Najib Danish, deputy spokesman for the interior ministry, told the Associated Press news agency.

INTERACTIVE: Afghanistan civilian casualties reaches record high

No one immediately claimed responsibility for the attack but Taliban fighters have attacked the top court and its employees in the past, as well as court buildings in the other provinces.

"This is not the first attack that targeted Afghan justice system," Al Jazeera's Qais Azimy, reporting from Kabul, said.

"In fact the exact location, the car park of the supreme court, was targeted before in June 2013 by a suicide bomber, which killed 17 people."

"That's why this part of the compound is heavily guarded and the employees of this court know that they are targets for Taliban," Azimy said.

The armed group has repeatedly issued statements threatening to target employees at Afghanistan's justice system "because they are not happy with the way they are working", our correspondent added.

Farah bombing

The Kabul bombing came hours after a roadside bombing killed the top government official of a district in western Farah province.

Taliban spokesman Qari Yusouf Ahmadi said the group claimed responsibility for that attack.

A Farah police spokesman, Iqbal Baher, told AP that Abdul Khaliq, the top official in the Khak-e-Safed district, was on his way home from the mosque when the explosion took place in the city of Farah, the provincial capital.

Taliban fighters frequently use roadside bombs and suicide attacks to target government officials as well as Afghan security forces across the country.