On Saturday, news broke that Dylann Roof, the 21-year-old charged with the murder of nine people in Charleston, South Carolina, had apparently published a lengthy manifesto on The Last Rhodesian, a website he registered in February, in which he described African Americans as genetically inferior to whites and defended legal segregation. The site, whose name refers to a former British colony governed by an apartheid regime, also contained images of Roof at plantations and in front of a Confederate museum in South Carolina—iconography of the state’s history of slavery. In the months before his attack, Roof reportedly spoke often of his hatred toward blacks and his desire to ignite a “race war” in the United States. The manifesto, a seething catalog of hatred encompassing Jews, blacks, and Hispanics, feels quite plausibly like the work of a killer who spared one person’s life reportedly so she could tell the world what he had done.

The manifesto showcases a character markedly different from those the world saw on Friday, when several relatives of the nine people slain inside Charleston’s historic Emanuel African Methodist Episcopal Church appeared in court and addressed Roof. The family members of the dead told Roof, a professed white supremacist, of their pain and anguish. But they also said they would forgive him.

“I will never be able to hold her again, but I forgive you,” a daughter of one victim said. “We have no room for hating, so we have to forgive,” said the sister of another. “I pray God on your soul.”

Given the heinous nature of the crime, the willingness of Charleston’s survivors to forgive was remarkable—and earned particular praise from President Obama. But the act of forgiving is more than just an expression of grace toward a wrongdoer. It’s also an effective tool in helping individuals and communities touched by tragedy accelerate the healing process.

In March, the Atlantic’s Olga Khazan profiled Everett Worthington, a professor of psychology at Virginia Commonwealth University whose mother was brutally murdered in a 1995 burglary. As it happened, Worthington’s own research examined the effects of forgiveness. So in the days after his mother’s death, he decided to employ a five-step process he had previously devised:

First, you “recall” the incident, including all the hurt. “Empathize” with the person who wronged you. Then, you give them the “altruistic gift” of forgiveness, maybe by recalling how good it felt to be forgiven by someone you yourself have wronged. Next, “commit” yourself to forgive publicly by telling a friend or the person you’re forgiving. Finally, “hold” onto forgiveness. Even when feelings of anger surface, remind yourself that you’ve already forgiven.

Worthington found that his approach worked—and that other examples confirmed his intuition. Studies have shown that forgiveness aids mental and physical health, while the opposite reaction—holding a grudge and harboring resentment—has the opposite effect. This can also be applied to entire communities touched by mass tragedy. In 2006, 32-year-old Charles Roberts stormed into a one-room schoolhouse in an Amish community in Nickel Mines, Pennsylvania and shot ten girls, killing five before turning the gun on himself. Despite enormous shock and grief, several of the victims’ family members appeared at the killer's funeral just days later. When Roberts’ aggrieved mother then announced plans to leave the community, relatives of the dead persuaded her to stay. Seven years later, CBS News reported that the elder Roberts had become the primary caregiver for a girl her son had wounded in the attack.

“Is there anything in this life that we should not forgive?” said Roberts.

An individual or community’s gift of forgiveness, however, does not obviate a society’s demand for justice. In a 2014 case described by the Atlantic’s Andrew Cohen, a Colorado prosecutor seeking the death penalty for a prison inmate charged with murdering a corrections officer engaged in a contentious dispute with the victim’s parents, who opposed capital punishment. After months of back and forth, the prosecutor finally agreed to forgo the death penalty. The defendant, whose attorneys believed him to suffer from mental illness, ultimately pled guilty and is now serving a life sentence.

In the wake of the Charleston murder, South Carolina governor Nikki Haley said that the state would “absolutely want” the death penalty for Dylann Roof. Even Roof’s own uncle said he would support his nephew’s execution, telling reporters that he’d volunteer to “be the one to push the button.”

Several months—at the very least—will pass before a judge determines Roof’s fate. But the decision of the victims’ relatives to forgive may ease some measure of their pain.