The son of a controversial Brooklyn imam who was arrested for abusing kids at an armed compound in New Mexico last week was training the youngsters to commit school shootings, new court documents allege.

Siraj Ibn Wahhaj was running weapons training at the dilapidated desert camp near the Colorado border where 11 starving children were found living in filthy conditions, prosecutors wrote in documents filed Wednesday.

Wahhaj is the son of the Brooklyn imam of the same name, who heads the Masjid At-Taqwa in Bedford-Stuyvesant — and was named as an unindicted co-conspirator in the 1993 World Trade Center bombing.

The younger Wahhaj was arrested last week when sheriffs came looking for his missing 3-year-old son, Abdul-Ghani, but instead found the other children barefoot and dressed in dirty rags.

When authorities arrived, Wahhaj was “heavily armed” with an AR-15 rifle, five 30-round magazines and four loaded pistols, according to Taos County Sheriff Jerry Hogrefe.

Wahhaj and four other adults from the camp are all facing child abuse charges, while Wahhaj is also accused of child abduction in Georgia.

Little Abdul-Ghani was not found at the filthy compound, but authorities say they found the remains of a child who they’re still working to identify.

The 3-year-old suffers from seizures and can’t walk, and Wahhaj left with the boy in December saying he wanted to perform an “exorcism” because his son is “possessed by the Devil,” the Atlanta Journal-Constitution reports.

With Post wires