Suspected Thousand Oaks mass shooter Ian David Long used legally purchased .45-caliber handgun: Officials At least 12 people were killed in the shooting.

The shooter in a killing rampage at a country western bar in Thousand Oaks, California, has been identified as former U.S. Marine Ian David Long, officials said.

Ventura County Sheriff Geoff Dean said Long was 28 years old and appeared to take his own life after being confronted in the Borderline Bar & Grill by a sheriff's deputy and a California Highway Patrol Officer.

He said Long was armed with a Glock 21 .45-caliber handgun that was equipped with an extended ammunition magazine. The sheriff said the gun normally holds 10 bullets and one in the chamber. He said it was unclear how many rounds the magazine held.

"We don't know if he reloaded his weapon or not," Dean said.

Dean said police had several minor run-ins with the alleged mass shooter, including an incident last April in which deputies were called to his home in Newbury Park on a report that he was acting erratically. He said detectives are investigating whether Long suffered from post-traumatic stress disorder.

"In April of this year, deputies were called to his house for a subject disturbing [the peace incident]," Dean said. "They went to the house, they talked to him. He was somewhat irate, acting a little irrationally. They called out our crisis intervention team, our mental health specialist, who met with him, talked to him and cleared him."

Dean said that the mental health specialist didn't feel Long was qualified to be taken "51-50," a California penal code designation for someone that needs to be involuntarily committed for psychiatric evaluation to protect themselves or others.

"He was left at that scene last April," Dean said.

Suspect's military background

Long served in the Marine Corps from 2008 to 2013 and achieved the rank of corporal as a machine gunner, according to his military record obtained by ABC News. He was deployed to Afghanistan from Nov. 16, 2010, to June 14, 2011.

During his military career, Long was awarded the Navy Unit Commendation, a Navy Meritorious Unit Commendation and a Combat Action Ribbon. He was also the recipient of the Marine Corps Good Conduct Medal, Sea Service Deployment Ribbon, an Afghanistan Campaign Medal, a Global War on Terrorism Service Medal and a National Defense Service Medal.

"The Corps extends its deepest condolences to the families of the victims in this senseless tragedy," the Marine Corps said in a statement Thursday.

After leaving the military, Long enrolled at California State University Northridge and attended classes through 2016, but did not graduate, university officials said in a statement.

Long was once a victim

In January 2015, Long was the victim of a battery at another bar in Thousand Oaks that deputies were called to investigate, Dean said.

Long was also involved in a traffic collision that his department investigated.

Long was once married

Long was married from 2009 to 2013, according to court documents.

Records indicate Long wed his ex-wife in June 2009 in Hawaii. The couple separated two years later in June 2011, and the divorce became official in November 2013.

Neighbors react

Neighbors told ABC station KABC-TV that Long lived with his 61-year-old mother and appeared not to have a job.

Julianne Hanson, who lives next to Long, told ABC News that she once called the police on the suspect when he allegedly got into a fight with his mother.

"This could have been avoided. He had issues," Hanson said.

Another neighbor, who spoke anonymously to ABC News, said Long would rarely go outside and that his mother told her that he was getting violent.

ABC News' Julia Jacobo and Timmy Truong contributed to this report.