With only a month to go, Mr. Anghouti’s family turned to the Imam Ali Popular Students Society, one of the few tolerated groups trying to prevent the executions of juvenile offenders. Since 2006, the group had managed to prevent 15 such executions.

The group’s work is based on a key principle in Iran’s interpretation of Islamic law that allows victims to seek retribution, avenging what has been done to them or their relatives — sometimes in eye-for-an-eye fashion — or to pardon offenders. In many cases, a pardon comes with cash compensation.

“We tell people that children are innocent,” said Zahra Rahimi, who runs the society with her husband, Sharmin Meymaninejad.

For the past year, she and other volunteers visited the family of Mr. Rezai, the victim. Sipping tea, sometimes taking along famous actors and other victims who had pardoned their attackers, they worked patiently to break down a wall of resistance and convince the relatives that it would be merciful and compassionate to allow Mr. Anghouti to live.

“Most of their neighbors and friends tried to push the Rezai family to get Safar executed,” said Mrs. Rahimi, who speaks English. “Instead we appealed to their kindness, stressing that those who can forgive are rewarded in heaven.”

Neither Iran’s judiciary nor the so-called blood money court likes volunteers intervening in the legal process, saying it could undermine the Islamic right of victims to avenge what has been done to them. The society’s permit was revoked under the former president, Mahmoud Ahmadinejad, but it was allowed to resume its work under the current president, Hassan Rouhani.

A week after the date was set for Mr. Anghouti’s hanging, the Rezai family, who declined to be interviewed for this article, finally relented and agreed to grant him a pardon in exchange for $50,000. That presented the problem of raising the money, since the Anghoutis are not a family of means. In the end, though, that proved to be the easy part. Within days, drawing in part on a campaign on Facebook — which is illegal in Iran but widely used with illegal software — the society raised 200 million tomans, about $13,000 more than was needed.