The gunman who killed 12 people at a country music bar was a former military machine gunner who was interviewed by mental health specialists months ago after a neighbour reported a disturbance.

Ian David Long, 28, apparently killed himself after the attack near Los Angeles.

He had joined the Marines and got married young. Within several years, he left the military and divorced, later enrolling at a university and most recently living with his mother.

Long’s service began when he was 18 and lasted nearly five years, including a seven-month tour in Afghanistan, according to the Pentagon. He was honourably discharged with the rank of corporal in 2013.

California Bar Shooting
A victim is carried from the scene (AP)

In April, a neighbour called authorities to report loud noises coming from the house that Long shared with his mother in a Thousand Oaks neighbourhood of well-manicured lawns and homes.

Deputies found Long “was somewhat irate, acting a little irrationally” and called in a mental health specialist, Ventura County Sheriff Geoff Dean said. That specialist assessed Long but concluded he could not be involuntarily committed for psychiatric observation.

“The mental health experts out there cleared him that day,” Mr Dean told reporters, less than 12 hours after the Wednesday night massacre.

They also were concerned that Long might be suffering from post-traumatic stress disorder, Mr Dean said, “basing that (on) the fact that he was a veteran and had been in the Corps”.

Long’s only other contact with authorities came after a traffic collision and after he alleged he was the victim of a violent encounter in 2015 at another bar in Thousand Oaks, Mr Dean said.

California Bar Shooting
Tom Hanson talks to the media outside his home (Richard Vogel/AP)

A next-door neighbour said he called authorities about six months ago when he heard loud banging and shouting come from Long’s ranch-style home.

“I got concerned, so I called the sheriffs,” Tom Hanson said outside his home as federal and local law enforcement officers searched Long’s house, where an American flag flew over the garage. “I was concerned because I knew he had been in the military.”

The Marine Corps said Long earned several awards, including a Combat Action Ribbon and a Marine Corps Good Conduct Medal. He was assigned to the 2nd Battalion, 3rd Marine Regiment, Third Marine Division in Kaneohe Bay, Hawaii.

Long’s mother, Colleen, posted Facebook photos of her son in his military uniform in 2010 and 2011.

“My Son is home, well sort of, back in Hawaii, soon to be in Cali come January, hooray!” she wrote on December 14 2012.

Another photo from 2014 shows Ian Long with his arm draped around his mother in front of Dodger Stadium. The two were wearing Dodgers T-shirts and smiles.

Court records show Long was married as a 19-year-old in Honolulu in June 2009, and he and his wife separated in June 2011 while he was deployed to Afghanistan.

The couple cited irreconcilable differences in divorce papers filed in May 2013, two months after Long left the Marines. Their marriage officially ended that November.

California State University, Northridge, said in a statement that Long was a student, last attending in 2016, but offered no further details.