Abdullahi Yusuf was having an identity crisis. Culturally marooned between home life with his traditional Somali parents and immersion in his everyday American school life in Minnesota, the Muslim teen gradually found his way to terrorist propaganda online.

In 2014, Yusuf was arrested before he could board a plane at Minneapolis airport, heading off to Syria to join Isis.

He had become part of a rare but not entirely unfamiliar pattern in which children of some immigrant families in North America and Europe feel alienated from society and a small but concerning few turn to jihad.

It was almost too late for Yusuf. But his story has had an unusual outcome.

Young extremists like him typically end up dead in the war zone or serving long prison sentences at home. But Yusuf, 21, was released by a judge in November and allowed to return to his parents in a suburb of Minneapolis.

In this extraordinary case, he is being integrated back into society after being sentenced to a unique “ideological rehab” program. He has spent the last year in a federal halfway house, reading philosophy, biography and literature, writing essays and poetry and reflecting on his life, his choices and his future. He was encouraged to debate with mentors and Muslim community leaders.

“It was a deradicalization program that was basically invented for Abdullahi as it went along,” said Jean Brandl, one of the lawyers on his defense team.

Yusuf had pleaded guilty to supporting a foreign terrorist organization and had testified against friends in a major trial of a group of Somali American Isis converts in 2016 in Minneapolis. Others who admitted wrongdoing and turned state’s evidence got lengthy prison terms. Only Yusuf has been deemed trustworthy enough for release, after two years incarcerated awaiting trial, then 12 months in the counseling program. He will be closely monitored by the authorities for the next 20 years and has restrictions on his internet use. He aspires to go to college.

“His transformation has been incredible. He went from being a surly, closed-down kid to this really open, warm, intelligent, thoughtful, introspective young man, who recognizes why he’d been attracted to Isis and why there are so many other options for him,” Brandl told the Guardian.

Leading experts on extremism say there should be much more focus on developing such rehabilitation as an option for dealing with homegrown budding terrorists, and warn of the dangers of ignoring its potential.

“The US, unfortunately, is about 20 or 25 years behind European countries in building these kinds of networks and programs. Intervention to counter violent extremism is really missing,” said Daniel Koehler, a fellow of George Washington University (GWU) and director of the German Institute on Radicalization and De-radicalization studies. He went to Minneapolis at the request of the judge in Yusuf’s case to assess the defendant before sentencing, including the risk of recidivism.

Koehler is prohibited by the court from discussing the case in detail. But he told the Guardian of his wider concerns.

“All signs that I see in the US are telling me there is a massive increase in homegrown extremism,” he said.

As a fraction of a Muslim population in the US estimated at 3.3 million, the numbers are minuscule but worrying to experts.

Koehler cited GWU’s program on extremism, which tracks criminal cases relating to Islamic State in the US. It measured 61 terrorism-related arrests in the US in 2015, the most in a year since 11 September 2001, and noted there have been 147 charged and 88 convicted of offenses related to Isis since March 2014.

Yet he was worried little was being done to prevent radicalization or to re-educate radicalized individuals when they are caught funding or trying to join Isis or while plotting attacks in the US.

Under the Obama administration, in 2014 three projects were launched to explore ideological rehab for people like Yusuf – in Boston, Los Angeles and Minneapolis. But they are barely under way and the future prospects of even this token effort are dubious under Donald Trump, Koehler said.

European anti-extremism re-education programs started in the early 1990s in Germany and Scandinavia, to deal with far-right white supremacists. Now those government projects have been adapted to try to return violent Islamists, or those who were determinedly heading that way, to productive society.

Britain has the government Prevent strategy, which is designed to intervene early when signs of radicalization are reported, though critics regard it as a form of community surveillance and stigma. But there are no official “rehab” programs for those convicted of crimes further down the extremist road.

Koehler said family therapy was key to ideological rehab and cited unofficial groups such as the UK’s Families for Life, started by Nicola Benyahia after her son became radicalized and died fighting for Isis in Syria.

There are numerous deradicalization programs in Saudi Arabia, which claim to be very successful, and one in Sri Lanka.

But there is no reliable research analyzing the outcomes, said Jessica Stern, a professor at Boston University, specializing in extremism, and the author of Isis: The State of Terror.

“The Saudis have reported very low recidivism but they have also had some significant failures and they’ve never made their data available for scrutiny. Also, they have strategies that are not going to be replicated elsewhere, such as finding the men a wife, buying them a car and getting them jobs,” she said.

Experts are watching Yusuf’s case with great interest, as it is understood to be the first of its kind in the US. “It’s an important experiment,” said Stern.

She pointed to a recent report citing statistics from the federal government’s National Counterterrorism Center that at the end of 2016 there were 300 terrorism offenders in US prisons, 90 of whom are due to be released in the next five years.

“At least some will probably reengage in terrorist activity … because they either remain radicalized or are susceptible to re-radicalization,” the center states.

Stern said there should be deradicalization programs in prison.

She has conducted research among the Somali-American community in Minnesota, where she found refugee families suffered disproportionate levels of economic hardship and discrimination.

Yusuf was born in a refugee camp in Kenya after his parents fled conflict and eventually made it to the US.

“I realized that mothers think their kids are safe when they see them inside on the computer but it turns out that’s where they can be most at risk from extremist propaganda,” she said.

“Some kids are almost living in a different world from their parents and then they are stolen away to be used as cannon fodder in someone else’s war. It’s heartbreaking,” she said.

Many of the disenchanted youth who turn to Isis reject the mainstream Islam they grew up with, as well as the secular and mainstream Christian American norms around them, and they become engulfed in the ideology of violent fundamentalism.

“They think they are getting the crack cocaine of Islam in Isis, they think they are doing something glamorous by going off to join the group – it’s five-star jihad to them,” she said.

Yusuf is currently barred from talking to the press. He completed his high school diploma and performed community service while in the counseling program.

The US district judge Michael Davis warned him that he risked being ostracized by parts of his community after testifying against some of the nine in his group of local extremists.

Yusuf’s main defense lawyer, the federal defender Manny Atwal, recalled an eruption in court as boys in the public gallery called him a liar and a traitor and got into a shouting match with Yusuf’s mother as he was testifying against his former friends.

“There was quite a ruckus and the judge saw that there was some backlash from the community,” she said.

His ideological rehab program was devised by a not-for-profit group in Minneapolis called Heartland Democracy, which specializes in civic engagement courses, particularly for alienated youth. He read and discussed the works of Sherman Alexie, Martin Luther King Jr, Malcolm X and the French philosopher Michel Foucault, trying to work through barriers, both mental and societal, to a sense of place in the community.

“Ideological rehab is astonishingly difficult to do in practice and requires one-on-one focus; it’s not just flicking a switch in the mind,” said John Horgan, professor of global studies and psychology at Georgia State University. “But there’s an urgent need for early intervention and alternatives to prison, because we’re losing the battle to prevent people becoming involved in terrorism.”

Yusuf’s lawyer Atwal is rooting for her former client, who is now under the supervision of the probation service. She gave him books by Mindy Kaling, the Indian American comedy writer and actor, and helped tailor his program at Heartland Democracy, after traveling to Europe to look at programs there.

“It was extremely brave of the judge to do this with Abdullahi,” she said. “But what are you going to do, just keep locking up these troubled 18- and 19-year-old youngsters?”