It remains to be seen what the suspect was after. City officials declined to discuss a possible motive for the attack, but they did say there was no immediate indication that the gunman had targeted anyone. The police chief, James A. Cervera, quelled rumors on Saturday that the suspect had recently been fired, and declined to say whether there had been friction between him and other employees.

But a person close to Virginia Beach’s city government, who was not authorized to speak publicly, said that the suspect had no history of behavioral problems until recently, when he had begun acting strangely and getting into physical “scuffles” with other city workers.

The person said that tensions had escalated in the past week, adding that the man had gotten into a violent altercation on city grounds and was told that disciplinary action would be taken.

[“Today, we all grieve”: 12 victims were identified in the attack.]

Officials said that the suspect was armed with two .45-caliber guns, at least one of which had a sound suppressor attached to it, and that both weapons had been purchased legally. He used extended magazines, which hold more ammunition than standard models, and reloaded several times in what the Virginia Beach police chief called “a long-term gun battle” with officers.

Two more firearms were found at the suspect’s home, officials said.

Few details in the suspect’s past point to the staggering violence that would mark the end of his life. He had no obvious criminal history, court records show, only several traffic violations over the years.