OAK CREEK, Wis. — The priests had gathered in the lobby of the sprawling Sikh temple here in suburban Milwaukee, and lunch was being prepared as congregants were arriving for Sunday services.

Instead of worshipers, though, an armed man stepped through the door and started firing.

In an attack that the police said they were treating as “a domestic terrorist-type incident,” the gunman stalked through the temple around 10:30 a.m. Congregants ran for shelter and barricaded themselves in bathrooms and prayer halls, where they made desperate phone calls and sent anguished texts pleading for help as confusion and fear took hold. Witnesses described a scene of chaos and carnage.

Jatinder Mangat, 40, who was on his way to the temple when he heard reports about the shooting, said he had tried to call his uncle, the temple’s president, but reached the head priest, Gurmail Singh, instead. “He was crying. Everyone was screaming,” Mr. Mangat said. “He said that my uncle was shot and was lying on the floor and asked why you guys are not sending an ambulance and police.”

Mr. Singh, he said, had locked himself in a bathroom with four other people, including two children.