The gunman who killed 12 people in a packed California bar was a decorated marine who served in Afghanistan.
Police said 28-year-old suspect Ian David Long died inside the venue and was found "down with a gunshot wound" when they got inside.
They believe he killed himself.
Long murdered 12 people including a police officer after storming into the Borderline Bar and Grill in Thousand Oaks, about 40 miles west of Los Angeles.
The former machine gunner in the US Marines opened fire with a handgun at around 11.20pm after first shooting a member of security.
Witness said he was wearing something resembling a ski mask.
"There were people hiding in restrooms, there were people hiding in attics," said Ventura County sheriff Geoff Dean.
"It's a horrific scene in there. There is blood everywhere".
He said the loss of Sergeant Ron Helus - who had served 29 years in the police and was due to retire - was "horrific and terrible".
The officer was on the phone to his wife when the emergency call came in, telling her: "Hey I gotta go handle a call. I love you. I'll talk to you later."
At least 30 shots were fired, sending hundreds of people toward the exits with some breaking windows to escape.
Police said Long used a Glock 21 handgun with an extended magazine designed to hold extra bullets - something that is illegal in California.
The bar had been hosting a night for university students, with country two-step lessons taking place.
Witnesses said the gunman fired several shots before throwing smoke bombs.
People screamed and ran, while some threw barstools through the windows and helped dozens to escape.
A trail of blood was visible on the street at the entrance of the venue. A number of victims with serious injuries were rescued and taken to hospital.
Police said they had previous contact with the gunman.
In April, he was found irate and acting irrationally when they were were called to his home. A mental health crisis team decided Long did not need taking into custody.
His motive is so far unknown and police were searching his property for clues.
The US Marines have confirmed details of his military career.
He served from 2008 to 2013 as a machine gunner, rose to the rank of corporal and served in Afghanistan from November 2010 to June 2011.
He earned several awards, including a combat action ribbon and a Marine Corps good conduct medal.
Long was part of the Third Marine Division based in Kaneohe Bay, Hawaii.
Tayler Whitler, 19, said he opened fire on a person working on the door, then began to shoot people at random.
"It was really, really, really shocking," she told KABC-TV. "It looked like he knew what he was doing."
Details have started to emerge about some of the victims.
Jason Coffman was earlier looking for his eldest son Cody, 22, but said he had now found out he was killed.
In tears, he told reporters that the last thing he said to him was "I love you."
President Donald Trump offered his condolences and said police had shown "great bravery".
In a tweet, he said he had been "fully briefed on the terrible shooting."
"God bless all of the victims and families of the victims. Thank you to Law Enforcement," he said.