MAREA, Syria/BEIRUT (Reuters) - Shaven-headed former jihadists filled a classroom in northern Syria as a Muslim cleric taught them a more moderate form of Islam than the version they had imposed in Islamic State s self-proclaimed caliphate. Their class was in a new rehabilitation center for Islamic State members set up in the town of Marea, north of Aleppo, in an area controlled by Syrian rebel groups backed by Turkey.  The center, set up in October, is meant to address a problem emerging across swathes of Syria and Iraq - how to handle thousands of people living there who joined Islamic State as it enforced its brutal rule. Islamic State used public killings and torture to enforce its draconian religious code, sexually enslaved captive women and slaughtered prisoners of war and members of enemy tribes. Its self-styled caliphate is now on the verge of defeat, having lost large tracts of its territory and most of its major towns and cities in both Syria and Iraq.     Although some IS members came from abroad out of conviction, many others were local people who joined the group to protect themselves or earn money, according to an official at the center. There are 25 ex-members now at the center where they take classes in religious doctrine and law. Psychological counseling is mandatory; some get individual sessions to help wean them off extremist ideology. The center is funded by the director as well as small donations, and its staff are all volunteers. Marea was besieged, but never captured, by IS. Last year, rebels backed by the Turkish army drove IS out of nearby areas.  Judges in rebel-held areas have tried Islamic State members who were captured or defected, and their sentences have included time at the center, guarded by a security team.  The center evaluates former jihadists each month and shares its views with local authorities, which base their release decisions on the center s recommendations.     Dressed in long-sleeved orange shirts and black vests, the ex-jihadists listened to lecturer Sheikh Mohammad al-Mahmoud, who asked them questions about Islamic rulings. No one answered.  Why did you join Islamic State and force Islam on people if you don t even know these answers?  he asked. Civilians across Syria and Iraq often reject former IS militants, holding them responsible for killing people from the area and destroying the towns and cities they entered. But not all former IS members at the center were armed insurgents, the center s lawyer said.   In the brutal administrative areas where Islamic State was, the overwhelming majority (joined) to protect itself or to have the bare minimum to live,  Ibrahim Najjar said. Some people joined just to obtain a canister of cooking gas, he added.  IS militants also tended to marry locals  daughters, he said, initially targeting the daughters of influential families and in later years marrying daughters of small families, calling on family ties to recruit fathers and brothers as informants. In an interview with Reuters at the center, former IS member Khalil Abdul-Ghafur spoke in formal Arabic - Islamic State s preferred version of the language - until the center director reminded him to switch back to Syrian dialect.  The 14-year-old from a village near Aleppo said he joined the jihadist group after insurgents arrived. He took lessons in sharia (Islamic law) and trained to use both light and heavy weapons, before IS dispatched him to al-Bab, near Marea.  He was wounded twice, both times returning to the militant ranks after he recovered. He only left IS when he found out rebels had detained his father over his membership of the group. Asked why he joined Islamic State, Abdul-Ghafur was at first silent.  I don t know what to tell you. They used to show us video clips,  he eventually said.  And they talk to us about heaven and freedom and all that.  He did not elaborate on life after Islamic State, only saying the center has good food, clothes and lessons. But he intends to go back to school when he is released, having not completed his education because his school was bombed. Ersin Khizri, 22, left his home in Ukraine and traveled to Syria with his wife and baby daughter to join IS ranks, in which he fought in Iraq. He left the group in January because he found it unjust, he said, turning himself in to rebels in Syria.  It s over: there is no more Daesh left,  he said, using an Arabic acronym for Islamic State.  I don t know what the outside situation is like.  The men in the center watch movies and play chess in their spare time, smoking the cigarettes that were banned under IS. They are divided into three categories: those who did not commit crimes against civilians, those who did, and foreign members. Housed in a former school, the center holds ex-jihadists from the Caucasus, Uzbekistan, Ukraine, Tunisia, Iraq and other countries. Hussein Naser, the center s director, said the men will stay there for no more than a year, mainly because it does not have the capabilities to hold them longer.  The goals of the center are to defeat the extremist ideology of the IS members that we have, ensuring their safety when they leave the center and that they can live with civilians,  Naser said. 