TULSA, Oklahoma - A federal judge in Tulsa found an Illinois man not guilty only by reason of insanity in a plot to bomb churches in Oklahoma.

Gregory Weiler II was accused of planning to destroy 48 churches in northeastern Oklahoma. Prosecutors say he was preparing to launch the attacks from his room in a motel near Interstate 44 in Miami, Oklahoma.

The Elk Grove Village, Illinois native was set to be tried by a judge at 11 a.m. Friday.

Minutes before the trial was set to start Friday morning, the defense and prosecutors agreed to a list of stipulations.

According to those stipulations, Weiler had bomb-making materials, a list of the churches and an outline of his plan in his motel room when Miami police arrested him on October 4, 2012.

Also according to the stipulations, Weiler was mentally ill and was "unable to appreciate the nature, quality or wrongfulness of his actions."

Judge Claire Eagan found that he had committed the offense with which he was charged, but found him not guilty only by reason of insanity.

Prosecutors say he'll be sent to a federal facility where he can be treated for his mental illness. His next court date is set for next month.