Despite the scale of the country’s problem, only about 100 children have attended formal deradicalization programs in Indonesia, Mr. Khairul said. His madrasa, the only one in Indonesia to receive significant government support for deradicalization work, can teach just 25 militant-linked children at a time, and only through middle school.

Government follow-up is minimal.

“The children are not tracked and monitored when they leave,” said Alto Labetubun , an Indonesian terrorism analyst.

The risks of extremist ideology being passed from one generation to the next are well-documented, and a number of Indonesians linked to the Islamic State are the offspring of militants.

The son of Imam Samudra , one of the masterminds of the 2002 bombing on the island of Bali that killed 202 people, was 12 when his father was executed in 2008. He joined the Islamic State and died in Syria at 19.

Mr. Khairul, whose father and uncles were members of a militant organization, said he understood the pull of family obligation. He was sent to prison in 2011 for armed robbery and for planning an attack on a police station. Before his conviction, Mr. Khairul taught four of his 10 children to fire weapons.

“Deradicalizing my own children was very difficult,” he said. “My wife and my children looked at me very strangely when I got out of prison because I had changed.”

Some of the children under Mr. Khairul’s care were taught to assemble bombs by family members. The parents of about half the students were killed in armed conflict with the Indonesian counterterrorism police .