London residents walk by the site of a 2019 terrorist attack.Henry Nicholls / Reuters

How do you unmake a terrorist? It’s an urgent question, particularly for Britain. About 220 people are in prison for terror offenses in the country, the majority of whom are Islamists. Until recently, 20-year-old Sudesh Amman was one of them. He was released in January after serving half of a three-year sentence for possessing extremist material. Ten days later, he was shot dead by police after stabbing two people in South London.

It was the second such attack in just over two months. At the end of November, 28-year-old Usman Khan killed two people near London Bridge, also in a stabbing attack, and was also shot dead by police. He had completed two deradicalization programs as part of his 16-year sentence, of which he had also served half. His victims were fellow attendees at a conference on prisoner rehabilitation.

The political debate in Britain since the latest attack has focused heavily on why Amman was freed. He had qualified for automatic early release from prison, yet was considered enough of a threat to be given police surveillance. The government now wants to change the law so terror sympathizers serve longer sentences, and are subject to more stringent assessment before release. But that won’t entirely solve the problem. “If you’re not rehabilitating prisoners, whether you let them out in two or four years isn’t very important,” said Arthur Snell, the former head of the British government’s anti-extremist Prevent program at the Foreign Office, who now runs a business-intelligence firm.

The courses Khan attended have not been fully evaluated, so their effectiveness is unknown. “I think we have to be very careful about saying someone has totally changed or has been cured,” the designer of one of them, Christopher Dean, said after the attack. Prime Minister Boris Johnson’s view on deradicalization is perhaps too bleak—he told reporters after last weekend’s stabbings that “the instances of success are really very few”—but the programs are resource-intensive, and Britain’s poorly funded prisons are badly equipped to provide them.

The standard program involves multiple counseling sessions that encourage offenders to rethink their identity. The aim is not simply to provide inmates with an alternative, nonviolent version of their religion—Snell, who interviewed suspected terrorist detainees in Iraq, told me it was remarkable “how little your average Islamist knows about Islam.” The men, who had come from Tunisia, Saudi Arabia, and other countries, talked more like students taking a gap year than religious fanatics. “They almost universally were young men without much sense of direction or status, and by joining the insurgency in Iraq, they felt for the first time in their lives that they mattered, that they were doing something important, almost heroic,” he said. “So basically, it’s a mental health issue.”

The first part of deradicalization, then, is understanding individuals’ psychological state, previous trauma, and personal circumstances—not just their political and religious beliefs. “We used to work with a group who worked in U.K. prisons,” Moustafa Ayad, a deputy director at the Institute for Strategic Dialogue, an international think tank, told me. “The way they described it was ‘deconstructing the terrorist and rebuilding the human.’ It’s not anything that’s set and planned.”

One of the hallmarks of a terrorist worldview is its rigidity: us and them, the righteous and the unbelievers. Cracking that is key to deradicalization, according to Rashad Ali, a former member of Hizb al-Tahrir, an Islamist group that Britain has repeatedly considered banning. Ali, now a senior fellow at the Institute for Strategic Dialogue, told me that creating a “cognitive opening” to allow people to reevaluate their beliefs was vital.

In the context of the penal system, this is difficult. Muslims are overrepresented in British prisons compared with the population at large, which a government report found “could chime with the radicalisers’ message of the victimisation of Muslims.” Following the July 7, 2005 bombings in London, the scope of terror offenses was widened to include “glorifying” and advocating terrorism. Those jailed for such offenses—overwhelmingly men—are prime targets for further radicalization in prison, to move them from glorification to action. As well as training prison imams in counter-extremism, the report recommended isolation for the most extreme prisoners.

The recommendation to segregate extremists hints at one of the fundamental problems of tackling Islamist radicalization in prison: These are closed systems that can develop strong hierarchies. There have been reports of sharia councils in British jails, and of high-ranking terrorists appointing themselves as “emirs.” Hamas and other banned organizations have compiled manuals on surviving prison, Ayad said, and these “handbooks” include advice on how to fool deradicalization programs. The Hamas guide warns that “easy prey falls for the hunter’s rope” and tells prisoners not to engage with guards or admit guilt, while other documents give advice on staging what Ayad calls “a fabricated play co-ordinated with your brothers.” In other words, how to make false confessions. He adds, “Everybody running a ‘derad’ program needs to know that these strategies exist. We should never take people at face value.”

In fact, Ali said, confusion and uncertainty are often better signs that deradicalization is working than strong pledges that a person has changed. “You’re talking about people with black-and-white views on ethics; all their answers are put on a plate for them; they have strong identities and membership of a group,” he told me. “If someone breaks that black-and-white view—moral ennui, that’s what they’re going to face. It’s like leaving a cult. There’s a sense of having no community, an identity crisis, a morality crisis, maybe even becoming more isolated.” The question then, Ali said, was “how do we reconnect them, create a sense of belonging, help them re-find themselves?”

One place offering an answer is Saudi Arabia. The country is a world leader in deradicalization. (Of course, you could also argue that the kingdom, the original home of Osama bin Laden, is also a world leader in radicalization.) The Prince Mohammed Bin Nayef Centre for Counselling and Care, as the name suggests, adopts a very different approach from Britain’s incarceration of extremists in overstretched prisons. The center has a swimming pool, art-therapy classes, and intensive counseling. More than 3,000 men have passed through it since it opened, and they are offered housing and other support—including help finding a wife—when they leave. It claims an 80 percent success rate.

Even if you take the Saudi program’s advertised success at face value, the lessons that democratic, liberal countries can learn from Saudi Arabia are inevitably limited—“If we were giving cars to former terrorists, we’d look really stupid,” Ayad said—but its investment in therapy, and focus on post-incarceration support, do highlight the issues with the British approach. In the U.K., prison deradicalization programs are voluntary, and short sentences offer no time to complete them anyway. Those sentences are themselves a problem: Several experts said they did not just fail to deradicalize extremists, but in many cases made the situation worse by increasing their sense of persecution and grievance. On release, British prisoners are given a £46 ($60) discharge grant and, if they are lucky, a place at a bail hostel. They are then expected to rebuild their life and find work largely on their own, except now they bear the stigma associated with a terror conviction.

Clearly, deradicalization can work—several academics currently working in the field are former extremists, and for more than a decade, one of Britain’s leading counter-extremism programs was run by a former al-Qaeda sympathizer who had traveled to Afghanistan. Was there any obvious difference between those who were successfully deradicalized and the others, I asked Snell. “A lot of them are very bright,” he said. They got interested in new ideas, learned new information—and their stark worldview began to crumble. Others, though, were unable to understand the moral choices they had made or the effects of their actions. “Not every individual can be changed,” Ali said. “Just like we can’t stop every terrorist attack … and that’s the conflict. We want to maintain that open society. There will always be individuals we can’t reach.”

Perhaps the best way to think of it is that every terrorist sympathizer who reaches prison already represents a failure—a demonstration of society’s inability to stop extremist ideas from flourishing. Snell acknowledges that the Prevent program, which was designed to tackle extremism, instead left many British Muslims feeling that their whole community was being stigmatized. It also initially failed to address the growing threat of far-right terrorism, and it tried to recruit unrelated public-sector workers, such as teachers, to spot potential extremists. But, Snell said, it did force the government to recognize the root causes—the isolation, the lack of role models, the foreign-policy narratives—that contribute to extremism.

Amman’s journey to that street in Streatham, South London, was a long path, strewed with failures. As the government responds to the most obvious—the fact that he was released when probation staff still believed he was a threat—it should not forget others. Could he have been deradicalized? Unlike many of the Islamist fighters Snell encountered, Amman had a strong knowledge of the Koran, according to his father. But in other respects he fit a common pattern of would-be terrorists: minor criminal convictions for possessing cannabis and an offensive weapon, a controlling relationship with his girlfriend, feelings of grievance and alienation. The year and a half he spent in prison appears to have driven him deeper into an extremist mind-set, rather than breaking it down.

“Punishment is in political vogue,” Snell told me. But punishment alone doesn’t unmake terrorists. No one in Britain would argue that extremists should be given an apartment, much less a spouse, but they do need a new life purpose to replace a perceived feeling of an existential struggle. They also need all the things that the British prison system struggles to give any inmate: mental-health support, education, training, and a future.

We want to hear what you think about this article. Submit a letter to the editor or write to letters@theatlantic.com.