A former US Marine killed 12 people as he opened fire in a California country music bar packed with college students.
America's latest mass shooting took place in the Borderline Bar and Grill in Thousand Oaks, a leafy, middle class city near Los Angeles.
The gunman Ian David Long, 28, had served in the Marines for five years until 2013, earning the rank of corporal, and had been deployed as a machine gunner to Afghanistan in 2010. He was believed to be suffering from post-traumatic stress disorder.
In April this year police were called to his home five miles from the bar, where he lived with his mother, because he was behaving angrily and erratically.
A mental health crisis team was drafted in but concluded Long did not need to be hospitalised.
Wearing a black hooded top and a balaclava over his face Long approached the Borderline, which was holding a regular "college country night," at 11.20pm on Wednesday.
He shot dead the bouncer before moving inside, killing more staff, throwing smoke bombs, and shooting customers at random, including people lying injured on the floor.
He then shot himself dead in the bar's office.
Long was armed with a legally owned Glock handgun, but it had a high-capacity magazine which is illegal in California.
The dead included the first police officer on the scene, Sergeant Ron Helus, 54.
Ventura County Sheriff Geoff Dean said: "He went in there to save people and made the ultimate sacrifice. It's a horrific scene in there. There's blood everywhere. It's hell."
He said no motive for the shooting had been established, but the gunman "obviously had something going on in his head".
Long dropped out of college in California in 2016 towards the end of a sports degree.
Last year Long explained on Shadowspear, an internet forum for special forces soldiers, his decision to drop out of his college sports degree.
He wrote: "Maybe the ego got the better of me but it took only one time for a 19-year-old athlete to talk down to me and tell me how to do my job that I realised this wasn't the career I wanted."
Police also had contact with him in 2015 when he was beaten up at a bar.
John Hedge, who was in the Borderline, said: "I just started hearing these big pops. Pop, pop, pop. I hit the ground. I look up. The security guard was shot, he was down. The gunman was throwing smoke grenades all over the place."
Another survivor, Teylor Whittler, 19, said she was on the dance floor and "dove to the ground". She said the gunman "had perfect form and looked like he knew what he was doing".
Describing the incident in April, Sheriff Dean said: "Officers felt he might be suffering from PTSD, the fact he was a veteran and had been in the corps.
"They called out our crisis intervention team, our mental health specialists who met with him, talked to him, and cleared him."
A recent survey named Thousand Oaks the third-safest city in the United States.
Donald Trump, the US president, said he had "been fully briefed on the terrible shooting" and ordered flags to be flown at half-staff at public buildings.
Six shot in club in Thousand Oaks plus deputy shot responding pic.twitter.com/6iSAzbzazr— Richard Winton (@LAcrimes) November 8, 2018
It was the latest chapter in America's epidemic of gun violence, happening 10 days after a gunman killed 11 people at a synagogue in Pittsburgh.
Jerry Nadler, a leading Democrat congressman in Washington, said an attempt to introduce a new law on universal background checks for gun buyers would begin when the House of Representatives convenes, with a Democratic majority, in January.
He said: "We must find a way to stop the senseless, and many times preventable, killings that are robbing our country of innocent lives."