NEWBURY PARK, Calif. — In photos that Ian D. Long’s mother proudly posted to Facebook, her son is a young Marine: smiling, crew-cut, in a crisp uniform. When he opened fire in a crowded bar late on Wednesday, killing 12 people, his face was covered and he was dressed in black. He was armed with smoke grenades and a high-capacity magazine for his pistol, and was full of an inexplicable rage.

What changed Mr. Long has this Southern California community scrambling for answers. The authorities said they suspected that he might have had post traumatic stress after a deployment in Afghanistan but was ultimately determined to have posed no threat. Neighbors said he was a solitary figure who lived with his mother, and often clashed with her.

[What stereotypes do you see around veterans and PTSD?]

As news of the mass shooting at the Borderline Bar & Grill in Thousand Oaks, Calif., spread to his former battalion, shocked veterans wondered if the troubles that led their fellow Marine to kill innocent civilians in a crowded bar had resided in him before the military, or if he had brought them home from war.

“I’m not surprised someone I knew ended up doing a mass shooting. We had another guy recently committed suicide by cops in Texas,” said Sam Tanner, who served with Mr. Long and described him as a friend. “Guys struggle. We’ve lost more Marines in our peer group to suicide than we ever lost in Afghanistan.”