Riyadh, Saudi Arabia — Khalid al-Hubayshi's career as an Islamic warrior came to an end with the siege of Tora Bora in Afghanistan. Ordered to retreat, he walked through snow for six days. He was captured by Pakistani forces, delivered to the Americans, and relocated to a cage in Cuba.

The young Saudi's break with militant jihadi ideology was not as swift. It started in Guantánamo, but ripened only after he returned home in 2005 to an unexpected reception. Mr. Hubayshi was treated to a mix of forgiveness, theological reeducation, psychological counseling, prison time, and cash.

With this carrot-and-stick approach, the Saudis aimed to bring Hubayshi back into the fold of society and ensure, as much as possible, that he left behind old ways of thinking.

His treatment is part of an ambitious rehabilitation program for all Guantánamo returnees and other militant inmates that is designed to counter the ideology motivating many young Muslims who have turned to violence at home and abroad.

Started in 2004, the program seeks to convince prisoners to abandon what officials call "deviant" or "misguided" beliefs. It is run by a committee that includes a religious subcommittee of about 100 clerics, a psychological-social subcommittee of about 30 psychologists and social scientists, and a security subcommittee, which determines suitability for release and monitors ex-prisoners.

It seems to have worked for Hubayshi, Guantánamo prisoner No. 155, who now lives with his new wife in Jeddah, where he works as a power plant technician. In a recent interview, he came across as affable and surprisingly free of rancor toward his former captors, and even appreciative of his own government's approach.

"We hope you learn from the past and we are going to take care of you," is how Hubayshi summed up this approach, which was extended to all 120 Saudis released so far from Guantánamo.

Even though the program has its critics in Saudi Arabia, many complain that financial incentives for the former militants are unjust, the Saudis have not gone soft – they are building five new prisons. But they say they cannot defeat terrorism by force alone.

When dealing with ideology, "locking him up is not enough," says Turki M. al-Otayan, assistant professor of psychology at the Interior Ministry's King Fahd Security College and coordinator of the psychological-social subcommittee. "We have to fix his mind, and change his emotions [in order] to directly change his behavior."

The Saudi program is among the most comprehensive. And while it's too soon to claim long-term success, officials say results are promising. About half of the approximately 3,200 prisoners who have gone through the program have left prison. Those who have backslid into militancy are "very few, I am sure less than 5 [percent], if it's not 1 percent," says Abdurrahman al-Hadlaq, director general of ideological security at the Ministry of Interior.

One reason for this success is that participants have been mostly sympathizers of terrorist networks who may have provided financial or logistical help; visitors to jihadi websites; and young men caught trying to go to Iraq or captured there.

Hard-core militants, who Dr. Hadlaq says make up about 10 percent of Saudi security detainees, have mostly declined to participate in the program. "We don't force anyone," he said, "because you are dealing with ideology."

The Saudi approach contrasts sharply with US handling of accused extremists, not only at Guantánamo but also in the US criminal justice system. There, the thrust has been to impose long prison sentences, even on defendants not involved in violence.

The Saudi government's announcement in June that it had arrested more than 500 people this year for extremist activities raises the question of whether the rehab program will be overwhelmed by the jihadi undertow.

"If we don't have these efforts, you might see 5,000 [arrested] instead of 500," says Hadlaq. "Certain issues that encourage the guys to be extremists are under our ability" to control, he added. Others, like conflicts in Iraq, are not.

When a Guantánamo detainee returns to Saudi Arabia, he is interrogated by Saudi intelligence to determine what, if any, charges they face. Most have been charged with traveling to a country Saudi passport-holders are forbidden to visit, drawing sentences of one to two years, according to an Interior Ministry spokesman, Gen. Mansour al-Turki.

Like other detainees in the program, the Guantánamo prisoners meet with psychologists to discuss problems they have, what they want to do in life, and what support they or their families need.

They also have individual sessions with Islamic scholars.

"A religious adviser ... speaks with you, and asks you what you believe and they discuss with you on what basis you believe in that, and they try to change your mind by convincing," says Hubayshi. "It's helped so many guys in the prison, they like it a lot."

Prisoners can request which sheikh they want to talk with, or ask for a different one if they do not like the one they are first assigned, Hubayshi says.

This spiritual counseling is supplemented by a six-week course that covers issues such as jihad, relations with non-Muslims, the authority to issue a fatwa (religious decision), and a proper understanding of takfir, the practice of declaring other Muslims to be apostates. Passing the final exam is mandatory.

"Our main goal is to open their minds and to correct their thoughts," said cleric Abdel Aziz al-Hileyl. "We teach them to be in the middle of Islam."

Financial incentives are a key part of the program. Hubayshi says Guantánamo returnees get monthly stipends – his is currently $800. He also was given a new Toyota Corolla and $20,000 to pay for his 2007 marriage.

The financial assistance and government help in finding jobs or furthering their education are essential for returnees to regain self-respect and avoid the temptation of their old networks, Hubayshi says.

In early 2007, the rehabilitation program launched its latest feature: halfway house to ease prisoners back into society.

Known as the Care Center, the sprawling walled property on the outskirts of Riyadh has a relaxed, camplike environment. Security is light, and the point is not to keep the prisoners in by force, but have them make responsible decisions on their own.

So far, the center has had 194 graduates, mostly would-be fighters caught heading to Iraq, or returnees from Guantánamo.

The latter group is encouraged by staff psychologists to vent their anger about how they were treated at the US detention center, but then urged to "forget about the past and try to look to the future," said Hadlaq. "You don't want them to think about … any kind of revenge."