A suicide bomber killed and injured dozens of Afghan supreme court employees when he struck commuter minibuses filling up for the afternoon drive home on Tuesday, in one of the deadliest Taliban operations this year.

It was the second big assault on the capital in as many days, after seven attackers holed up on a construction site to fire rockets on Kabul airport. That group fought for hours but killed no one apart from themselves and did little damage to their target.

Yesterday's attack was the work of one man in an explosives-packed Toyota Corolla, and caused terrible carnage in a leafy residential area that was on the civil war frontlines but had been largely peaceful since.

"Seventeen civilians have been killed and 39 wounded," said Mohammad Zahir, head of the city's criminal investigation department. "There were two women and two children among the dead."

The explosion near the back gates of the court building was so powerful that one bus was blown from the tarmac into a nearby yard, and debris was hurled over a six-storey apartment block to land in a street 50 metres away.

"I had gone to buy some fruit when the blast hit," said Ezatullah, 25, a driver. "I looked back and one of the buses, which was already full of passengers, had disappeared from the road." One man sitting in Ezatullah's bus was killed and all the others were injured. Hours later he watched in despair as a tow truck prepared to shift the twisted remains of his vehicle.

Residents of surrounding blocks stared down through window frames stripped of glass, as police picked through the devastation.

"After the blast you couldn't see, the air was full of smoke. But I could hear people screaming for help, they couldn't even move. There were bodies and blood all around," said Ehsan Jalalzai, a resident who rushed out to assist. "It is disgusting to live here."

A Taliban spokesman said the bombing, carried out by a Kabul engineer named Abdul Wahid, was a revenge attack aimed at judges. "Employees of the court were sentencing our mujahideen to death or a long time in prison, and not providing good justice to the nation," said Zabihullah Mujahid.

But it is unlikely that the battered minibuses held anyone who made such decisions, as top officials have private cars and sometimes bodyguards, while those crammed into group transport are mostly clerks, cleaners, cooks and other low-level staff.

The blast had disturbing echoes of an assault on a court in western Farah province in April, when insurgents went room-to-room executing civilians, and more than 40 people were killed. Then too the Taliban claimed the attack and said it was to free captured fighters.

The killings violate both the insurgents' own code of conduct, which calls on fighters to minimise civilian casualties, and international law, analysts and activists say. "The Taliban repeatedly targets government employees and makes statements that suggest it considers anyone working for or associated with the government or foreigners a legitimate target, a stance completely out of line with the Geneva conventions," said Heather Barr, Afghanistan analyst for Human Rights Watch.

This week the United Nations warned that the outlook for civilians in Afghanistan was gloomy, with deaths and injuries in the first five months of the year up by around a quarter compared with the same period of 2012.

Mokhtar Amiri contributed reporting