A Detroit-area man accused of making threats against a church has pleaded guilty to gun charges.

Khalil Abu-Rayyan of Dearborn Heights was not charged with terrorism-related crimes. But investigators say he's made threats against a church, police and others in support of Islamic State.

His lawyer says the 22-year-old Abu-Rayyan was simply trying to impress an undercover agent.

Abu-Rayyan pleaded guilty Tuesday to making a false statement to get a firearm and illegally possessing a firearm. The plea wasn't part of any deal with prosecutors. He's been in custody without bond since February.

An expert found Abu-Rayyan was competent to face charges. He'll get his sentence on Jan. 9. The maximum sentence is 10 years in prison on each charge.