Mr. Yaqoub’s lawyer, Mr. Khorami, used his session with the appellate judges to try to convince them that Mr. Yaqoub had been wrongly tried as an adult. He produced a tazkera, the Afghan identity document, saying that his client had been 17 at the time of the killing. Although the trial-court judge believed this document had been forged, the appeals panel deemed Mr. Yaqoub underage and commuted his death sentence to 10 years in prison.

The argument that there was no evidence on who had struck the blow that killed Farkhunda made sense to both the appellate court and the Supreme Court, according to people close to the courts. “It’s very difficult to determine responsibility if you don’t know what killed her,” a person close to the Supreme Court said, speaking on the condition of anonymity because court employees are not allowed to talk to the news media.

So the judges commuted the other three death sentences to 20-year prison terms.

They also reviewed the evidence that the fortuneteller was not at the shrine when Farkhunda was killed and ruled that he was not guilty because he had not been present. They exonerated a ninth police officer, so that in the end, only 10 were disciplined at all.

When the appeals court’s ruling became public in July, Farkhunda’s family and many women’s groups were stunned to find out that they had been given no chance to make their case. Farkhunda’s brother Mujibullah said the new verdict was a travesty.

“You saw that boy who hit her with that big stone, and the court said he’s underage,” he said. “Even if he is underage, he knows how to hit, but he doesn’t know how to answer for his actions.”

Female lawyers who followed the case said the verdict showed Afghanistan’s cultural bias against women. “There was some discrimination against women,” said Najla Raheel, a young lawyer who takes cases on behalf of women, even when they cannot pay, and who was appointed by Mr. Ghani to lead the team representing Farkhunda’s family in the appeal to the Supreme Court. “Some government officials didn’t want 49 men punished for the death of one woman.”

Soon after the new verdict, Farkhunda’s family asked Mr. Ghani’s wife, Rula, who had taken an interest in the case, to help them get temporary visas to leave the country. They felt the appeals verdict signaled that the public did not support them.