The man who shot dead 26 people in a Texas church once escaped from a mental hospital and made death threats against his military superiors while serving in the US Air Force, according to a police report.
The Federal Bureau of Investigation said meanwhile that the bureau has recovered the phone belonging to the gunman, Devin Patrick Kelley, but has been unable to access the device so far.
Kelley died of a self-inflicted gunshot wound on Sunday after killing 26 people, including an unborn child, with an assault rifle at the First Baptist Church in the small Texas town of Sutherland Springs.
He wounded 20 others.
The 26-year-old served in the Air Force from 2010 to 2014, when he received a bad conduct discharge.
He was court-martialled in 2012 for assaulting his wife and stepchild, fracturing the baby's skull, and sentenced to 12 months behind bars.
According to an El Paso, Texas, police report obtained by Houston TV station KPRC, Kelley escaped in June 2012 from a psychiatric facility where he had been sent ahead of his assault conviction.
The person who reported him as missing from Peak Behavioral Health Services told police that Kelley "suffered from mental disorders."
He said Kelley was a "danger to himself and others" and had been "caught sneaking firearms onto Holloman Air Force base," where he was stationed.
Police were also told that Kelley had been accused of "attempting to carry out death threats" against his "military chain of command."
While receiving the missing persons report, police were told that Kelley had been located and taken into custody.
The authorities have said that Kelley's rampage may have stemmed from a "domestic situation," adding that he had sent threatening texts to his mother-in-law, who worshiped at the First Baptist Church but was not there on Sunday.
The Air Force has said Kelley's domestic violence conviction was not passed on to a national database that lists persons barred from purchasing firearms.
FBI special agent Christopher Combs said Kelley's phone has been sent to FBI headquarters in Quantico, Virginia.
"I can assure you we're working very hard to get into the phone and that will continue until we find an answer," Combs told reporters. "I don't know how long that's going to be to be quite honest with you.
"It could be tomorrow, a week or a month. We don't know yet."
Combs pointed out without naming specific cases that increased encryption and password protection on phones has posed difficulties for the FBI in the past.
The most notable case involved the iPhone of the man behind the December 2015 attack in San Bernardino, California, where the FBI took Apple to court to compel it to grant access to the device.
The FBI finally managed to get into the iPhone through other means.
"Law enforcement, whether it's at the state, local or federal level, is increasingly not able to get into these phones," Combs said, declining to confirm what type of phone Kelley had used.
FBI Director Christopher Wray spoke of the problem in a speech last month.
Wray said that over an 11-month period, the FBI had been unable to access the content of over 6,900 mobile devices, "even though we had the legal authority to do so."
"That's more than half of all the mobile devices we attempted to access in that timeframe," he said.
"That's a huge, huge problem," he said. "It impacts investigations across the board — narcotics, human trafficking, counterterrorism, counterintelligence, gangs, organised crime and child exploitation."