The young boy whose remains were found at a compound in New Mexico died in a religious ritual conducted because his father believed he was possessed by demons, prosecutors alleged Monday.

The boy's remains were discovered Aug. 6 after Taos County authorities raided the ramshackle compound near Amalia, where they found five adults and 11 children, ages 1 to 15, at least two of whom prosecutors said Monday were being trained to attack schools, banks and other institutions.

The boy hasn't officially been identified, but Siraj Wahhaj, a well-known imam at the Al-Taqwa mosque in Brooklyn, New York, has said the child was his grandson, Abdul-ghani Wahhaj.

Abdul-ghani, who would have turned 4 years old last week, disappeared from his home in Georgia in December. A nationwide search eventually led authorities to the compound in Taos, which was set up by the imam's son, Siraj Ibn Wahhaj, 40, who authorities allege had kidnapped his son.

At a detention hearing for the younger Wahhaj and the four other adults on Monday, prosecutor John Lovelace indicated that the remains were those of Abdul-ghani, saying the death occurred in February during "a ritual intended to cast out demonic spirits from Abdul-ghani Wahhaj."

Prosecutors said the other children were told that Abdul-ghani would be resurrected as Jesus and would identify corrupt institutions and people for them to attack, teachers, military and law enforcement officials and financial institutions. The children were given tactical training on how to clear rooms and how to shoot firearms, prosecutors alleged.

Defendants, from left, Hujrah Wahhaj, Lucas Morton, Siraj Wahhaj and Subbannah Wahhaj enter district court in Taos, N.M., for a detention hearing, on Aug. 13, 2018. Roberto E. Rosales / The Albuquerque Journal/Pool via AP

Prosecutors said that Wahhaj and a second man arrested at the compound, Lucas Allen Morton, 40, his brother-in-law, were heavily armed when they were taken into custody and that some of the children were carrying ammunition.

All of the adults are charged with 11 counts of child abuse. Wahhaj is also charged with interfering with a parent's custodial rights, while Morton is also charged with harboring a fugitive. Bond was set at $20,000 apiece.

Taos County Sheriff Jerry Hogrefe testified that an AR-style rifle, a five-shot Smith & Wesson revolver, a 9mm Kimber semiautomatic pistol, a 9mm Glock pistol and body armor were found at the scene. In a 100-foot-long tunnel on the property, authorities found a .308-style sniper rifle, a .30-30 lever-action rifle and another Glock, he said.

Hogrefe agreed with the defense's argument that it would be prudent to teach teenagers how to use firearms safely in the remote desert. But he said one of the boys at the compound, who was found with a holster, told investigators that Siraj explicitly ordered him to arm up during the raid.

FBI agent Travis Taylor testified that one of the children said the family ended up in New Mexico because they believed they had received a message from God. They started traveling west after Wahhaj returned from a visit to Saudi Arabia last year and told his wife that he wanted a divorce, Taylor said.

Court documents say Abdul-ghani struggled with seizures and hypoxic-ischemic encephalopathy, a birth defect caused by lack of oxygen and blood flow. Taylor said one of the other children told investigators that Abdul-ghani was possessed by demons and that the suspects believed he was dead and was able to walk only because the demons kept him alive.

They believed that when the last demon was exorcised, Abdul-ghani would come back as Jesus, Taylor said.

Initially, the firearms practice was intended only to train the children to defend the compound from the government, Taylor quoted one of the children as having said. Eventually, however, the plan changed to one of preaching to others — and kidnapping or killing them if they didn't accept the message, he said.

In urging 8th District Judge Sarah Backus to hold the defendants without bond, Lovelace warned that they were capable of "future violent actions," alleging that they were in the thrall of "magical thinking."

"This family was on a mission, and it was a violent one, and it was a dangerous one," he said.