DEARBORN HEIGHTS (WWJ) — A local man is being accused of planning a terrorist attack on a Detroit church in the name of Middle Eastern terror group ISIS.

Court files say that conversations online with undercover agents revealed that 21-year-old Khalil Abu-Rayyan of Dearborn Heights was planning to open fire at an unnamed Detroit church.

READ MORE: Ribs RnB Music Festival Kicks Off This Weekend In Downtown Detroit

According to the documents, Abu-Rayyan was under federal surveillance starting in May 2015. It was found that Abu-Rayyan was posting and retweeting ISIS-supporting posts on Twitter, along with photos of him firing an AK-47 and an AR-25 at a gun range.

Abu-Rayyan allegedly told an undercover agent through social media about his plans for an attack.

Click here to read the complaint (.pdf format)

“I tried to shoot up a church one day,” Abu-Rayyan posted, the complaint said. “It’s one of the biggest ones in Detroit. I had it planned out. I bought a bunch of bullets. I practiced reloading and unloading. But my dad searched my car one day and he found everything. He found the gun and the bullets and a mask I was going to wear.”

The church in question went unnamed in the documents, but was said to have 6,000 members. Abu-Rayyan allegedly went on to explain why he picked the church as a target.

READ MORE: Judge Says Michigan Gov. Whitmer Won't Have To Testify In Abortion Lawsuit

“It’s easy, and a lot of people go there,” the post read. “Plus people are not allowed to carry guns in church. Plus it would make the news. Everybody would’ve heard. Honestly I regret not doing it. (If I) can’t go do jihad at the Middle East, I would do my jihad over here.”

Abu-Rayyan is being held on gun and drug charges, but has not yet been brought up on terrorism charges.

Abu-Rayyan was pulled over for speeding on Oct. 7 when officers found an unlicensed pistol inside his car and noticed a strong smell of marijuana. He told police during questioning that he was trying to hide the gun from the officer.

He pleaded guilty to possession of marijuana and is scheduled for trial on a concealed weapon carrying charge.

Court documents say that days after pleading guilty to marijuana charges, Abu-Rayyan took to social media again and told the undercover agent that he wanted to kill his arresting officer — who was in the hospital following a heart attack — and that he carries a “large knife or sword” in his car in case he gets into a fight.

“I would gladly behead people if I needed to,” he allegedly told the agent. “It is my dream to behead someone.”

MORE NEWS: MDHHS Lifts No-Contact Recommendation In Huron River Chemical Spill

[Stay with and LISTEN LIVE to WWJ Newsradio 950 for the latest]