A Marine veteran clad in black and armed with a .45-caliber Glock handgun shot his way into a Southern California bar crowded with college students and unleashed hell before turning the gun on himself, officials said Thursday.

When it was over, 12 others, including a sheriff's sergeant who tried to stop the carnage, were also dead and many more were wounded.

While investigators identified the gunman as 28-year-old Ian David Long and tried to establish a motive, the nation was once again forced to grapple with tragedy and embark on the all-too-familiar rituals of mourning after yet another mass shooting.

When the shooting started late Wednesday at the Borderline Bar & Grill in normally peaceful Thousand Oaks, about 40 miles northwest of Los Angeles, several hundred people were inside for a "college country night," Ventura County Sheriff Geoff Dean said.

"It's a horrific scene in there," Dean said. "There's blood everywhere."

The sheriff said the gunman first shot a security guard standing outside, then "stepped inside, turned to the right, shot several other security and employees and began opening fire inside the nightclub."

He added, "We have no idea what the motive is at this point."

Officials from the FBI and Bureau of Alcohol, Tobacco, Firearms and Explosives are assisting the Ventura County Sheriff's Office in processing evidence at the scene and at the shooter's home.

SIGN UP HERE FOR BREAKING ALERTS FROM NBC NEWS

As police prepared to search the suspect's home, Dean said Long had a history of minor run-ins with police. As recently as April, he said, deputies were called to his house after reports of a disturbance, and they found Long to be "somewhat irate," and "acting a little irrationally."

There was some discussion about whether Long might be suffering from post-traumatic stress disorder, Dean added. But ultimately Long was assessed by a mental health specialist who cleared him and didn't feel he was eligible to be taken in for involuntary psychiatric evaluation.

Dean said Long was also the victim of an assault at a bar in 2015, the sheriff said.

The weapon Long used in Wednesday night's shooting was a legally purchased Glock 21 with an extended magazine, Dean said. Long, who officials had earlier described as a heavily tattooed white man, did not appear to be carrying a driver's license or any other form of IDs, Dean said earlier on "Today."

Sergeant 'died a hero'

The slain police officer was identified as Sgt. Ron Helus, a 29-year veteran of the department with a wife and son who was looking to retire in the next year.

"He was hard-working, he was totally committed, he gave his all and, tonight, as I told his wife, he died a hero," an emotional Dean said. "He gave his life to save other people."

Helus, 54, spoke to his wife by phone just before he went inside the bar, telling her, "I gotta go, I love you, call you later," according to Dean.

President Donald Trump sent two tweets paying tributes to the authorities and victims. He praised the "great bravery shown by police" and said, "God bless all of the victims and families of the victims."

As Helus' body was carried by hearse from Los Robles Regional Medical Center in Thousand Oaks to a coroner's facility in the city of Ventura, residents lined the highway and many saluted the passing motorcade.

Meanwhile, the grieving father of 22-year-old victim, Cody Coffman, was mourning his slain son.

"I talked to him last night before he headed out the door," a weeping Jason Coffman told reporters. "First thing I said was please don't drink and drive. Last thing I said was, 'Son, I love you.' That was the last thing I said."

Then, breaking down, Jason Coffman said, "Oh my God."

The first reports of shots being fired occurred around 11:20 p.m. Wednesday (2:20 a.m. Thursday ET), police said.

Three minutes later, Helus arrived at the bar with a California Highway Patrol officer, Dean said. Hearing more gunfire, Helus raced inside and "was struck multiple times with gunfire," Dean said.

The patrolman was able to drag Helus out of the line of fire, but he died in the hospital hours later, the sheriff said.

A SWAT team, FBI and others officers arrived soon after. When they entered the bar they found it littered with bodies, shooting survivors huddling in terror, and others desperately trying to get out.

"They found people hiding in restrooms, people hiding in attics," Dean said. Other witnesses described people using bar stools to break windows and escape.

Several witnesses reported seeing what they described as smoke bombs going off inside, although police could not confirm that.

Six off-duty, unarmed police officers from various agencies were at the bar when the shooting began, according to Dean.

"I’ve already spoken to a parent who said, 'They stood in front of my daughter,'" he said. "It was amazing."

People comfort each other near the scene of Wednesday's mass shooting in Thousand Oaks, California. Mark J. Terrill / AP

Ten to 12 people suffered injuries of varying severity, with others with more minor wounds escaping and taking themselves to the hospital, Dean added.

The Los Robles Regional Medical Center confirmed later that 10 of the 11 victims they saw were treated for gunshot wounds and lacerations and released. None were admitted and the only patient who did not go home was Helus.

Pepperdine University, in nearby Malibu, said that some of its students were believed to have been at the bar and that it was working "to identify and provide support to those students."

Thousand Oaks was ranked the third-safest city in the United States this year, according to the data analysis website Niche.

"I've been a cop for 41 years," Dean said. "But I've learned it doesn't matter what community you're in, it doesn’t matter how safe your community is. It can happen anywhere."

Survivors like John Hedge described in cinematic detail what it was like when the shooting erupted.

"I was actually about to leave when you start hearing pop, pop, pop. It sounded like fireworks or something," he told NBC News. "My stepdad dove and took cover and yelled at me, 'John, hit the deck! Hide!' So I get down. And the gunman started opening fire on the cashiers, the people working the cash register on the front desk."