Causing the biggest death toll in a single attack since 2011, the militants, strapped with explosives, stormed the governor's compound in the capital of Farah province, bordering Iran, where the trial was taking place.
Thirty-four of the dead were civilians, the rest Afghan security forces, the governor's spokesman Abdul Rahman Zhwandai said. The Taliban said all 10 of its fighters who were on trial were freed.
"We sent several warnings to those in the Farah government, telling them not to work there," Taliban spokesman Qari Yousuf Ahmadi said.
The attack will add to concerns about how Afghan security forces will manage once NATO-led combat troops withdraw by the end of next year.
Farah province, where U.S. and Italian troops are stationed, saw a sharp deterioration in security last year, with increased targeting of government officials and a regrouping of insurgent networks, according to the Afghanistan Analysts Network (AAN).
The vast distances between towns in Farah, sandwiched between Helmand and Herat, may allow for more Taliban gains in the near future, AAN said in a report last month.
Civilian casualties in the NATO-led war, now in its twelfth year, decreased in 2012 after rising for five years, according to the United Nations. More than 80 percent of civilian casualties are caused by insurgents.
The last major attack inflicting a high civilian death toll was in July last year, when a suicide bomber killed a prominent anti-Taliban politician and 22 other guests at a wedding in the northern Samangan province.
In December 2011, bombers struck Shi'ite Muslim religious observances in Kabul, killing 58 people in a rare sectarian attack.