A gunman who killed two people at a Kroger supermarket in Jeffersontown, Ky., on Wednesday tried to enter a predominantly black church minutes before the attack, the police said on Thursday.

The man, Gregory Bush, 51, of Louisville, was arraigned Thursday on two counts of murder and 10 counts of wanton endangerment. He was ordered held with bail set at $5 million. The victims, Vickie Lee Jones, 67, and Maurice E. Stallard, 69, were both black, while Mr. Bush is white.

The United States attorney for the Western district of Kentucky, Russell M. Coleman, said in a statement on Friday that his office was investigating the attack as a possible hate crime. The son of a witness said his father heard the gunman make a racist remark during the episode, though the police said they could not confirm that account.

The police said there was no indication that Mr. Bush knew either of the victims, nor did he have any known connection to the grocery store. Mr. Bush has a history of mental illness, Chief Sam Rogers of the Jeffersontown Police Department said at a news conference on Thursday. Court records show that he also had a long history of domestic violence charges, and had previously been barred from possessing a firearm.