Twelve people have been killed and around a dozen more injured after a gunman opened fire in a packed bar hosting an event for students in southern California.

The suspect entered the Borderline Bar and Grill in Thousand Oaks, 40 miles northwest of Los Angeles, at 11.20pm local time and started firing into a crowd of around 200 people.

A sheriff's sergeant responding to reports of the shooting died after being "struck multiple times with gunfire", Ventura County sheriff Geoff Dean said.

The 29-year-old suspect, described as dressed all in black with a mask covering his face, died inside the bar. His death took the total number of fatalities to 13.

"It is a horrific scene in there, there is blood everywhere, and the suspect is part of that," Mr Dean said.

The sheriff added that around 10 other people were shot and injured and an additional 10-12 were walking wounded. No other information on the victims was immediately known.

"We don't know who shot anybody at this point," Mr Dean said, adding that the suspect was yet to be identified.

Authorities do not yet know how the gunman, who was armed with a .45-caliber handgun, died, or what his motive might have been.

Witnesses said the suspect shot a security guard standing at the door of the bar before entering the building and throwing "smoke grenades all over the place". He then fired into the crowd, apparently at random. A female cashier was said to be among the victims.

Thousand Oaks shooting: in pictures Show all 10 1 /10 Thousand Oaks shooting: in pictures Thousand Oaks shooting: in pictures Emergency services attend the scene AP Thousand Oaks shooting: in pictures People walk away from the scene EPA Thousand Oaks shooting: in pictures Emergency service vehicles flood the scene Reuters Thousand Oaks shooting: in pictures Police officers secure the road EPA Thousand Oaks shooting: in pictures Police block an intersection by the scene of the shooting AP Thousand Oaks shooting: in pictures A woman hugs with her father at the scene EPA Thousand Oaks shooting: in pictures Survivors are interviewed at the scene EPA Thousand Oaks shooting: in pictures Police officers interview people at the scene AFP/Getty Thousand Oaks shooting: in pictures People wait near the scene of the shooting AP Thousand Oaks shooting: in pictures People walk away from the scene of the shooting AP

At least 30 shots were fired before people inside the bar began using chairs to smash windows to escape, the witness said. Police were at the scene three minutes after the first 911 call was made.

Teylor Whittler is hugged by her father after she fled the Borderline Bar (EPA)

Donald Trump said he had been "fully briefed on the terrible shooting" and praised law enforcement, saying "great bravery" had been shown by the police.

Sergeant Ron Helus, the police officer killed outside the bar, had a wife and son and was due to retire within the next 12 months after 29 years service.

"Ron was a hardworking, dedicated sheriff's sergeant who was totally committed," Mr Dean said, "and tonight, as I told his wife, he died a hero because he went in to save lives."

Teylor Whittler, 19, was on the dance floor when the shooting started. She said: "I heard the gunshot, turned around and saw him shoot a couple more times.

"Within a split second everyone yelled ‘get down’. I ran to where the back door is, and everyone dog-piled on top of each other. It was silent for a couple of seconds and then all of a sudden a couple of guys started running to the back door and said ‘get up he’s coming’.

"It was a huge panic, everyone tried getting up, and some guy came behind me, lifted me up and said ‘let’s go’. I got a bar stool thrown at my head because they were trying to use it to get out.”

Father takes daughter away from Thousand Oaks shooting scene

Nick Steinwender, student body president at nearby California Lutheran University, rushed to the scene when he heard about a shooting at the bar where he knew friends and fellow students were inside.

"It was chaos, people jumping out of windows, people hopping over gates to get out," he told KABC-TV.