TOPEKA, Kansas: A man charged with plotting a suicide bomb attack on a US military base to help the Islamic State group was mentally ill and was acting strangely only days before his arrest, according to a Muslim cleric who said he was counseling him at the request of the FBI.

John T. Booker Jr., of Topeka, is accused of planning a suicide attack at Fort Riley, about 70 miles (112 km) west of Topeka. Prosecutors allege he told a Federal Bureau of Investigation informant he wanted to kill Americans and engage in violent jihad on behalf of the terrorist group, and said he believed such an attack was justified because the Qu’ran “says to kill your enemies wherever they are,” according to a criminal complaint.

Authorities arrested Booker on Friday as he was trying to arm what he thought was a 1,000 pound (455 kg) bomb outside the Army post, according to prosecutors. The criminal complaint filed in federal court in Topeka charges him with three crimes, including attempting to use a weapon of mass destruction.

The top federal prosecutor for Kansas also charged another Topeka man, Alexander E. Blair, 28, with failing to report Booker’s plans to authorities. The complaint alleges that Blair and Booker shared some “extremist views” and that Blair loaned Booker money to rent space to build and store a bomb.

Imam Omar Hazim of the Islamic Center of Topeka said that two FBI agents brought Booker to him early in 2014 for counseling, hoping to turn the young man away from radical beliefs. Hazim said the agents told him that Booker suffered from bipolar disorder, characterized by unusual mood swings that can affect functioning. Hazim said he expressed concerns to the FBI about allowing him to move freely in the community at their first encounter.

Hazim said he later heard that two others were involved in a bombing plot with Booker. He said the FBI told him they were undercover FBI agents and that the sting was arranged to get Booker, “off the streets.”

“I think the two FBI agents set him up, because they felt at that point someone else might have done the same thing and put a real bomb in his hands,” Hazim said.