"A role model that we will copy in other places," says the chief of Indonesia's National Counter-terrorism Agency. Credit:Amilia Rosa The school's founder, Khairul Ghazali, says terrorists' children are taught to hate the army and police. So the fact some of his students now say they want to be police officers or join the army is a measure of the success of Al-Hidayah's deradicalisation program. "I have seen significant changes in them," says Ghazali, a softly spoken ustadz (religious teacher) and father of 10. We are talking in the school's serene green-walled office, donated by the Medan police chief. It is sparsely furnished, with a whirring fan and a posy of white flowers on the table. In the corner is a cluster of trophies and a book entitled Dakwah Entrepreneurship a la JK – "dakwah" is a word for preaching Islam, "JK" is Indonesian Vice-President Jusuf Kalla. "The kids are nicer here," 17-year-old Rizky Alfandi tells us. "The kids in my old school who were bigger than me were bullies. They would hit me and because their bodies were bigger I couldn't really fight back." Stigma is a problem for the children of terrorists. But after coming to Al-Hidayah, Ghazali says, the students are no longer angry or moody. "They no longer hate the government, they no longer hold grudges. Most importantly they are forgetting the memory of how Detachment 88 tortured their parents. We managed to make them forget about that. It has reached the point where they believe what their parents did was wrong."

Students Andika, Abdullah Azam Al-bara, Rizky Alfandi and Dimas Anggara. Credit:Amilia Rosa Region at risk When Indonesia's National Counter-terrorism Agency (BNPT) chief Commissioner General Suhardi Alius heard about the school he offered to build a mosque and provide youth programs. He sees Al-Hidayah as a role model and hopes to open similar schools run by ex-terrorists in West Nusa Tenggara and Kalimantan. Ghazali says the stigmatised children of terrorists are no longer angry or moody after coming to Al-Hidayah. Credit:Amilia Rosa

"If children are not included [in deradicalisation programs] they will follow their parents' ideology," Suhardi says. "The proof is Imam Samudra's son." Imam Samudra was executed in 2008 for his role in carrying out the 2002 Bali bombings. His eldest son was killed fighting for Islamic State in Syria seven years later. "He became more militant than his dad," Suhardi says. Students take a break at Al-Hidayah Islamic School. Credit:Jewel Topsfield The spectre of terrorism looms large in Indonesia amid fears that battle-hardened Indonesian militants who have fought in Syria and – closer to home – in Marawi in the Philippines will return to Indonesia. According to Detachment 88 figures in May, there were 510 identified Indonesian Islamic State supporters in Syria and Iraq, including 113 females. A further 84 had been killed, more than 400 deported and 62 who went to Syria and had some connection with a militia group have returned home. Another 20 Indonesians are believed to be among the foreign fighters in the Philippines.

The May 2017 takeover of the southern Philippine city of Marawi by an alliance of pro-IS militants will have ramifications for the region long after the Philippines military retakes the city, according to a recent report by the Jakarta-based Institute for Policy Analysis of Conflict. "In Indonesia it has helped unite two feuding streams of the pro-[IS] movement, inspired 'lone wolf' attacks and caused soul searching among would-be terrorists about why they cannot manage to do anything as spectacular," the report says. On Saturday, Australia and Indonesia will co-host a meeting with four other countries in the region on foreign fighters and cross-border terrorism. Indonesia will share its experiences combating terrorism using a "soft approach", including deradicalisation. In the wake of the 2002 Bali bombings, which killed 202 people, including 88 Australians, counter-terrorism forces in Indonesia and Australia forged a close relationship. In February, the Australian government announced a second phase of the Australia-Indonesia Partnership for Justice. In the $37 million partnership, which will run from this year until 2021, Australia will work with Indonesian civil society organisations, including on prison reform and programs promoting religious tolerance and countering radicalisation.

Within days of being released from jail last year, one of the parents at Al-Hidayah tried to join IS in Syria. He was deported but that hasn't assuaged Ghazali's concerns. He says the eight terror attacks in Indonesia since the January 2016 blasts in Central Jakarta have all been linked to IS. Leaflets distributed in Jakarta and on social media have called on IS supporters in Indonesia to use Marawi as an example. "Indonesia is highly vulnerable to be used as an [IS] headquarters in Asia," he says. Deradicalisation When Ghazali talks to the 20 children of terrorists at Al-Hidayah about deradicalisation, he knows who to use as an example: himself. "In Islam, it is haram (forbidden) to commit a crime against anybody," he says. "Don't do what I did and your parents did and kill people." On August 4, 2011, Ghazali was sentenced to six years' jail for his involvement in the armed bank robbery in Medan and a fatal attack on the Hamparan Perak police office. "I wasn't physically involved but I was the remote who controlled it," he says. He was found guilty of sheltering the terrorists in his home and receiving 2 million rupiah ($200).

Ghazali was just 17 when he joined Abdullah Sungkar, one of the founders of the Islamist terrorist group Jemaah Islamiyah, which was behind the Bali bombings. His family and whole community in Medan were members of Negara Islam Indonesia, also known as Darul Islam, a group that aimed to establish an Islamic state in Indonesia. (The Indonesian government officially recognises six religions – Islam, Protestantism, Catholicism, Hinduism, Buddhism and Confucianism – and its state ideology, Pancasila, enshrines pluralism and democracy.) "At the time I wanted to go to Afghanistan to fight for Islam," Ghazali says. "It started when the Soviets invaded Afghanistan and tried to convert Muslims into communism. It aroused a lot of sympathy in Indonesia because we wanted to protect our fellow Muslims." Under the Suharto regime, Islamists were suppressed and so Ghazali fled overseas, first to Malaysia and then Thailand for 12 years, where he trained in weaponry and bomb making. When Suharto fell in 1998, Ghazali returned with the dream of Indonesia becoming an Islamic state. He was involved in planning and recruiting for a string of terror attacks that shook Indonesia, beginning with the 2000 Christmas Eve church bombings that killed 18 people. But after his arrest in 2010, Ghazali saw the suffering inflicted on the children of combatants: "They would drop out of school and become child labourers because the main family breadwinner was arrested or shot."

Ghazali watched his own children become angry and depressed. "In prison you can't do much other than think. I came to the realisation there was something wrong with what we considered jihad [just war]. Women and children – even Muslims – were also victims in the attacks. Destroying and killing was the wrong jihad." Ghazali penned a book in prison called Mereka Bukan Thaghut (They are not evil). The "they" in the title refers to police and government officials. Counter-terrorism expert Susan Sim writes that the response of the jihadist movement was swift and robust. Leading ideologue Aman Abdurrahman penned a rebuttal, also from prison, called Yaa ... Mereka Memang Thaghut (Yes, they are indeed evil). "Rehabilitated terrorists prepared to speak out against their former comrades and their acts of violence can add another wedge in the new deterrence," Sim writes in Analysing Different Dimensions and New Threats in Defence Against Terrorism. "Their perceived betrayal of the group can potentially destabilise it from within by undermining internal cohesion and trust. Captured terrorist leaders have a street cred that is hard to ignore, even when they abandon the cause." Ghazali was branded a kafir (infidel) and put in isolation after receiving death threats. But he was determined that once released he would create something instead of destroying. "This is my form of jihad – building the boarding school."

Education the front line It's recess time and we are sitting cross-legged on a platform overlooking the fishponds and vegetable plantations that help bankroll the school. The students are an enthusiastic and affectionate bunch. Many wear Islamic tunics and peci (caps), others T-shirts. One, incongruously, has paired a T-shirt spruiking First Blood – a hardcore band from San Francisco – with a sarong. They are peppering us with questions. What inventions come from Australia? How cold are the winters? What games do we play in Australia? They love soccer – a barefooted pair kick a ball in the dust as we talk – but have not heard of cricket. It's our turn to ask a question. What do you think of terrorism/terrorists? (They are the same word in Indonesian.) There is a chorus of "salah" ("wrong"). One student, who wants to be a police officer so he can make money to send his parents to Mecca, disagrees. Why? "What they did was target immorality, so it was not wrong."

We assume he is is talking about the Bali bombings, although he does not say so explicitly. The others argue that terrorists may target immorality but there are many innocent victims too. We ask Abdullah Azam al-Bara, who wants to be an ustadz (religious teacher), what he thinks. Azam, 14, was forced to drop out of school in third grade due to his family's financial problems while his father was in prison. He emphasises that terrorism is wrong but struggles to find the words to express it. "Wasn't your father a terrorist?" the other boys ask. Azam denies this. In fact Azam's father is Jumirin, alias Sobirin. He was released just last year from Indonesia's equivalent of Alcatraz – Nusakambangan – after spending seven years behind bars for a number of terrorism-linked bank robberies. Ghazali is not surprised when we tell him that Azam had denied his father was a terrorist. "To them, their father is not a terrorist, their father is a mujahid [one engaged in jihad]," he says. "If you had asked me before if I was a terrorist, I would have said I was a mujahid. Terrorist is a label put on you by the government."

Ghazali established the school using money from speaking engagements and the royalties from his four books, including "They are not evil". He used the skills once deployed to recruit people to Jemaah Islamiyah to recruit the children of terrorists to his Islamic boarding school. "I persuaded parents that their children were not getting the education they needed," he says. "I told the children: 'Do not follow in the footsteps of your dad. This [attending school] is also a form of jihad'." We ask Ghazali if he would still like Indonesia to become an Islamic country. "Yes," he replies. "But not by using terror."