Recognizing that informal tribal law would remain the choice for most Afghans, the United States in recent years began spending money to support local councils and connect them more publicly with the government. But a review by an independent monitoring organization found that instead of bolstering the government’s image, the effort mostly reinforced the primacy of the informal courts — of which Taliban justice could be considered a radical extension, wielding a mix of Pashtun tradition and extreme interpretations of Islamic law.

President Ashraf Ghani made cleaning up the judiciary one of his first pledges in office, but it will be a daunting task. According to a poll released by Gallup in October, just 25 percent of Afghans expressed confidence in the nation’s judicial system.

The Taliban have seized on this discontent. In some areas, they have set up mobile courts to reach villages outside their zones of influence. They hold hearings two days a week in the southern borderlands, requiring plaintiffs to produce evidence and witnesses. In Kunar, Taliban legal experts embed with militant commanders to provide services to locals and the fighters.

While few Afghans recall the Taliban rule from 1996 to 2001 with any fondness, the lack of corruption in justice then was seen by some as a strong suit. Bribes were uncommon. The power of litigants and their extended clans mattered less. The implementation of Islamic law, or at least the rural Afghan version of it, was standard.

But the brutality at the heart of Taliban justice has not been forgotten. Mass public executions were common. Minor offenses, like cutting beards short or listening to music, often brought fierce beatings as punishment. Yet the government system still compares unfavorably in the eyes of many Afghans. “There are no people who think that government justice is better than the Taliban’s,” said Amanullah, a schoolteacher from the Andar district of Ghazni. “Even if someone feels they have had their rights violated, there is an appeals procedure within the Taliban system.”

Yegan, a 65-year-old farmer in Kunduz, said he went to the Taliban to resolve a dispute with his sister over their inheritance.

He admits that he did not want to share their father’s land. But after reviewing the case, the Taliban forced him to adhere to Quranic law and give her a share.