A man who tried to shoot a pastor during a service at a Pennsylvania church because ''God told him to do it'' was thwarted when his gun didn't fire and he was tackled by a congregant, authorities said.

The chaos at the Jesus' Dwelling Place Church in North Braddock took place Sunday while the service was being livestreamed, state police said in a news release.

Bernard J. Polite, 26, of Braddock entered the church just after 1 p.m. and walked toward the front while the Rev. Glenn Germany was giving a sermon, police said. The pastor told WTAE-TV in Pittsburgh that Polite smiled at him and they made eye contact just before Polite pointed the gun at him. Germany then ducked out of the way as a male congregant tackled Polite.

Germany and the congregant then worked together to wrest the gun away from Polite, who was soon subdued and held until state troopers arrived.

Polite said ''God told me to do it'' and that he planned to shoot Germany and ''wait to be arrested'' so he could go to jail and clear his mind, according to court documents. He faces numerous charges, including aggravated assault and attempted homicide, and was being held Monday without bail at the Allegheny County Jail. State police said they they didn't know if Polite has an attorney, and county court records did not list one.

The body of a shooting victim was found in a home near the church where Polite had been shortly before going to the church, county police said. The county Medical Examiner's office identified the body Monday as Derek Polite, 56, of North Braddock, but did not say if he was related to Bernard Polite.

Polite was not known at the church, officials said. He wandered over to the church after hearing music coming from there, according to court documents.

''I am feeling grateful that I woke up this morning and that I am here. It could have gone an opposite direction,'' Germany told The Associated Press on Monday. "But God has intervened and I am grateful for him.''