Ventura County Sheriff Geoff Dean says sheriff's Sgt. Ron Helus responded to the scene and was shot after he entered the building. Eyewitnesses said people used chairs to break the windows and escape.
There were hundreds of people in the bar when the attack began.
Dean says around 10 other people were shot and wounded.
The bar was holding its regular "College Country Nights" on Wednesday night when the gunman dressed in black opened fire inside the bar.
An undated photo of Ventura County Sheriff Sgt. Ron Helus, who was shot and killed in a mass shooting at a Thousands Oaks, Calif., bar, November 7, 2018.
According to the website Gun Violence Archive, more than 12,000 people have been killed using firearms in the USA so far this year, including about 3,000 people under 18.
Some students from Marjory Stoneman Douglas High School in Parkland, Florida - where 17 were killed in February - have taken up a public campaign for gun law reform in recent months but little in the way of change has emerged from legislators.
Asked what the scene inside the bar was like, Sheriff Dean said, "Like ... hell".
The FBI are now at the scene of the shooting and the bomb squad has been requested. "From what I heard, the gunman started shooting at the front desk".
NASA's Hubble spots cosmic smiley among colourful galaxies
The Hubble telescope was launched on April 24, 1990, via the space shuttle Discovery from Kennedy Space Centre in Florida. As per NASA, stars take birth within a giant cloud of gas which they call stellar nurseries.
"We knew he was going there, to know he may not come home is another thing", Jason Coffman told the station.
Pepperdine University confirmed several students were at the bar during the shooting.
The 28-year-old left as a corporal in March 2013 and recently was living with his mother in the Los Angeles suburb of Thousand Oaks.
"I'm just reeling, riding on adrenaline right now", he said.
"I tried to get as many people to cover as I could", Knapp said.
He said a highway patrol officer happened to be pulling someone over nearby.
Bar patron describes what she saw when shooting broke out in Thousand Oaks.
"It was really, really, really shocking", she told KABC-TV as she stood with her father in the Borderline vehicle park.
Around midday, the body of the slain sheriff's officer was taken by motorcade from the hospital to the coroner's office.
Firefighters are honoring Helus with a giant USA flag raised by two ladder trucks over the route. He was identified as Sheriff's Sgt. Ron Helus, a 29-year veteran about a year from retiring.