The gunman who killed 26 churchgoers in Texas fled from a mental health clinic in 2012, according to a police report.
El Paso officers who detained Devin Kelley five years ago were told he was "a danger to himself and others".
Kelley had been sent to the hospital after he was court-martialled for assaulting his ex-wife and stepson during a stint in the US Air Force.
He was "attempting to carry out death threats" against "his military chain of command", BBC reports citing the police report.
Officials say the assault charge should have legally barred him from owning guns.
El Paso police arrested Kelley at a bus terminal in downtown El Paso in June 2012,
Officers wrote that Kelley had fled Peak Behavioral Health Services in Santa Teresa, New Mexico, about 100 miles (160km) away.
The person who reported him missing from the facility told police Kelley "suffered from mental disorders".
Kelley "had already been caught sneaking firearms onto Holloman Air Force Base", the report adds.
Later that year, Kelley pleaded guilty in a military court to repeatedly assaulting his wife and toddler stepson.
He was sentenced to one year in a US Navy prison.
FBI investigators said on Tuesday they have been trying to unlock Kelley's mobile phone, to better understand what led him to carry out the mass shooting.
According to the Houston Chronicle newspaper, the 26-year-old killer had shown up at the First Baptist Church of Sutherland Springs with his children for an annual fall festival five days before the shooting.
Authorities have said 26 people were killed in Sunday's assault, including the unborn child of a pregnant woman who was among the dead. Another 20 people were wounded, half of them still listed in critical condition as of Tuesday.
The massacre, which ranked as the deadliest mass shooting by a single gunman in Texas history, and one of the five most lethal ever in the United States, rekindled an ongoing debate over gun ownership, which is protected by the Second Amendment of the US Constitution. Guns are part of the fabric of life in rural areas.
However, US President Donald Trump told reporters he believed stricter reviews of gun purchases would not have stopped the rampage, reports Reuters.