TWELVE people including a sheriff’s sergeant were killed in a mass shooting inside a crowded southern California bar by a gunman who is then believed to have taken his own life.

The killer was identified as Ian David Long, a 28-year-old former US Marine, with investigators trying to find the motive for the attack at a venue hosting a country music evening for students.

The hooded killer used a smoke bomb and a handgun, sending hundreds of people fleeing in terror.

Ventura County Sheriff Geoff Dean said his department had several previous contacts with Long, including a call to his home in April, when deputies found him angry and acting irrationally.

The sheriff said a mental health crisis team was called at the time and concluded Long did not need to be taken into custody.

Patrons at the bar screamed in fear, shouted “Get down!” and used bar stools to smash second-floor windows and jump to safety as gunfire erupted at the Borderline Bar & Grill, a Thousand Oaks venue popular with students from nearby California Lutheran University.

The dead included 11 people inside the bar and a sheriff’s sergeant who was the first officer inside the door.

Sheriff’s sergeant Ron Helus was shot after he entered the building. The 29-year veteran of the force, who had a wife and son, planned to retire in the coming year.