THE Washington navy base gunman had been suffering serious mental problems and hearing voices, according to US officials.
Sources say Aaron Alexis, 34, had been treated for paranoia and a sleep disorder since August.
The US navy had not declared him mentally unfit, which would have rescinded a security clearance that he had from his earlier time in the Navy Reserves.
Family members told investigators that Alexis was being treated for his mental issues.
Alexis used a valid security pass to get inside the navy complex where he killed 12 people.
Alexis, a defence contract employee, was described as a Buddhist who had also had a violent temper, complained about the navy and being a victim of discrimination, and had several run-ins with the law, including two shootings.
President Barack Obama lamented "yet another mass shooting" and promised to make sure "whoever carried out this cowardly act is held responsible."
He has been powerless to get gun control legislation passed by Congress.
Stunned Washington authorities have questioned today how Alexis could get clearance to enter a Navy base given his record of brushes with the law.
Investigators are still searching for a motive. Alexis had been given clearance to enter the base on the bank of the Anacostia River, despite two gun-related brushes with the law and a discharge from the Navy Reserve in 2011 after a series of misconduct issues.
"It really is hard to believe that someone with a record as chequered as this man could conceivably get, you know, clearance to get ... credentials to be able to get on the base," Washington Mayor Vincent Gray told CNN.
He said automatic US budget cuts known as sequestration could have led to skimping on vetting that would have barred Alexis from the heavily guarded base.
"Obviously, 12 people have paid the ultimate price for whatever was done to have this man on base," Gray said.
CNN reported that Alexis had contacted two Veterans Administration hospitals recently. He was believed to be seeking help for psychological problems, the network said.
Military personnel are generally banned from carrying weapons on military installations in the United States but most people with proper credentials are not routinely checked for firearms.
The three gunshot victims, including a Washington police officer severely wounded in the legs, were doing well, Janis Orlowski, the chief medical officer at Washington Hospital Center, told NBC's "Today" program.
Police shot Alexis in a gun battle after he entered the Naval Sea Systems Command headquarters about 8:20am (1220 GMT) and started picking off victims in a cafeteria from a fourth-floor atrium, witnesses said.
Alexis was armed with an AR-15 military-style assault rifle, a double-barrelled shotgun and a handgun, a federal law enforcement source said.
The shooting was the worst attack at a US military installation since Army Major Nidal Hasan opened fire on unarmed soldiers at Fort Hood, Texas, in 2009, killing 13 people and wounding 31.
Alexis, a contract employee, had legitimate access to the Navy Yard and used a valid pass, the FBI said. Authorities have not addressed how he could have gotten weapons onto the base.
Alexis, a one-time Texas resident who was known to worship at a Buddhist temple, served full time in the US Navy Reserve from May 2007 to January 2011, becoming an aviation electrician.
He was recently hired as a civilian information technology contractor to work on the Navy and Marine Corps intranet. He was given a security clearance classified as "secret", his company's chief executive said.
Alexis was arrested on September 4, 2010, in Fort Worth, Texas, on a misdemeanour charge of discharging a firearm. The case was dropped when investigators determined he was cleaning his gun and it accidentally fired, Tarrant County prosecutors said.
He was also arrested in Seattle in 2004 for shooting out a construction worker's car tires in an anger-fueled "blackout" triggered by perceived "disrespect," according to the Seattle Police Department.