THOUSAND OAKS, Calif. — Terrified patrons hurled barstools through windows to escape or threw their bodies protectively on top of friends as a Marine combat veteran killed 12 people at a country music bar in an attack that added Thousand Oaks to the tragic roster of American cities traumatized by mass shootings.
Dressed all in black with his hood pulled up, the gunman apparently took his own life as scores of police converged on the Borderline Bar and Grill in Southern California.
The motive for the rampage late Wednesday night was under investigation. The killer, Ian David Long, 28, was a former machine gunner and Afghanistan war veteran who was interviewed by police at his home last spring after an episode of agitated behavior that authorities were told might be posttraumatic stress disorder.
Opening fire with a handgun with an illegal, extra-capacity magazine, Long shot a security guard outside the bar and then went in and shot employees and customers, authorities said. He also used a smoke bomb, according to a law enforcement official who was not authorized to discuss the investigation publicly and spoke on condition of anonymity.
The dead included a veteran sheriff’s deputy who rushed in to confront the gunman, and a 22-year-old man who planned to join the Army, a freshman at nearby Pepperdine University, and a recent Cal Lutheran graduate.
‘‘It’s a horrific scene in there,’’ Ventura County Sheriff Geoff Dean said in the parking lot. ‘‘There’s blood everywhere.’’
Survivors of the rampage — mostly young people who had gone out for college night at the Borderline, a hangout popular with students from nearby California Lutheran University and other schools — seemed to know what to do, having come of age in an era of active-shooter drills and deadly rampages happening with terrifying frequency.
Several of the survivors said they were also at the outdoor country music festival in Las Vegas last year when a gunman in a high-rise hotel killed 58 people.
Many of the estimated 150 patrons at the Borderline dived under tables, ran for exits, broke through windows or hid in the attic and bathrooms, authorities and witnesses said.
‘‘Unfortunately our young people, people at nightclubs, have learned that this may happen, and they think about that,’’ the sheriff said. ‘‘Fortunately it helped save a lot of lives that they fled the scene so rapidly.’’
Matt Wennerstrom said he pulled people behind a pool table, and he and friends shielded women with their bodies after hearing the shots. When the gunman paused to reload, Wennerstrom said, he and others shattered windows with barstools and helped about 30 people escape. He heard another volley of shots once he was safely outside.
The tragedy left a community that is annually listed as one of the safest cities in America reeling. Shootings of any kind are extremely rare in Thousand Oaks, a city of about 130,000 people about 40 miles from Los Angeles, just across the county line.
Scores of people stood in line for hours to donate blood for the wounded, and all morning, people looking for missing friends and relatives arrived at a community center where authorities and counselors were informing the next-of-kin of those who died.
Jason Coffman received the news that his son Cody, 22, who was about to join the Army, was dead. Coffman broke down as he told reporters how his last words to his son as he went out that night were not to drink and drive and that he loved him. ‘‘Oh, Cody, I love you, son,’’ Coffman sobbed.
President Trump praised police for their ‘‘great bravery’’ in the attack and ordered flags flown at half-staff in honor of the victims.
Authorities searched Long’s home in Newbury Park, about 5 miles from the Borderline bar, for clues to what set him off. ‘‘There’s no indication that he targeted the employees. We haven’t found any correlation,’’ the sheriff said.