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.