By Jennifer Medina, Dave Philipps and Serge F. Kovaleski

New York Times News Service

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 Long, who was found dead at the bar, 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 determined to have posed no threat. Neighbors said he was a solitary figure who lived with his mother, and sometimes clashed with her.

Long shot a security guard at the entrance and opened fire into the crowd. Patrons dropped to the ground, dashed under tables, hid in the bathroom and ran for exits, stepping over bodies sprawled across the floor.

“I remember looking back at one point to make sure he wasn’t behind me,” said Sarah DeSon, a 19-year-old college student.

The shooting inside the bar, a favorite local hangout for 25 years that hosted line-dancing lessons and allowed students in starting at 18, and where on Wednesday night several college women were celebrating their 21st birthdays, began about 11 p.m. Witnesses described sudden chaos. Among the estimated 130 to 180 people at the bar were five off-duty police officers, enjoying the night like the other partyers. As patrons dove for cover, the sounds of glass shattering and gunshots rang out in the cavernous bar.

Teylor Whittler, a young woman inside the bar, saw the gunman quickly reload and fire again. “He knew what he was doing,” she said. “He had perfect form.”

As news of the mass shooting at the Borderline Bar & Grill in Thousand Oaks, California, 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 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.”

Another friend said he could not match the Marine he knew, who had been given a good conduct award, with the man who barged into the bar.

“He was a really good guy. He gave me the Bible I still carry today,” said Dewayne Pettiford, who was his roommate in the military. “We were trained as machine-gunners, so you know you are capable of doing something like this. But that he did it makes no sense. It is against all our values.”

Long, 28, lived with his mother on a quiet street of palm trees and tidy ranch houses. Neighbors said that when Long moved in after leaving the military, they regularly heard yelling in the Long house, and sometimes at night, gunfire.

Tom Hanson, 70, who has lived in the home next to the Longs for decades, called 911 about a year ago, concerned about the yelling.

“I didn’t know if he was going to kill himself or what he would do, so I called the sheriff to investigate,” he said.

Another neighbor, Donald Macleod, who lived behind the Longs, said Thursday morning that agents in FBI jackets were searching the house, where he once heard gunfire.

According to Sheriff Geoff Dean, Long was the victim in a January 2015 fight at a different bar in Thousand Oaks.

The sheriff’s office said that after a disturbance at the house in April, mental health specialists had talked to Long, discussing his service in the Marine Corps and whether he had PTSD. They determined that he was not an immediate danger to himself or others.

Long joined the Marine Corps after high school in August 2008, just as the Marines were preparing for a bloody campaign in Afghanistan to take the Helmand province from the Taliban, according to Marine Corps records.

The battalion deployed in 2010 to Helmand, but Long was held back because the battalion had limited space and he was seen as a low-performing Marine, said Tanner, who was also held back.

“He was a little strange,” Tanner said.