(TNS) — The gunman who killed 26 people at a Texas church last weekend escaped a mental health facility in 2012 and made death threats to his superiors in the Air Force, according to newly revealed police records.

The gunman, Devin Kelley, was also accused of rape in 2013, a case that later was dropped, according to newly released documents from the county sheriff's department.

The new revelations show that Kelley had a documented history of erratic behavior and violence when he was allowed to buy four guns between 2014 and 2017, apparently because of the Air Force's failure to report his history of domestic abuse to databases used by gun dealers to perform background checks on buyers.

Kelley had previously attended the First Baptist Church in Sutherland Springs, Texas, but the pastor "did not think that he was a good person and did not want him around his church," Wilson County Sheriff Joe Tackitt told CNN on Tuesday. "But he said, 'How do I run him away from my church?'"

The new details about Kelley's mental health issues came in El Paso police records, first obtained by Houston's KPRC-TV, that were filed after Kelley disappeared from the Peak Behavioral Health Services center in Santa Teresa, N.M., on June 13, 2012.

Kelley "suffered from mental health disorders" and had apparently been sent to the facility during his Air Force court-martial proceedings on charges of beating his wife and stepson in 2011 and 2012, according to the police records.

An incident report described Kelley as "a danger to himself and others as he had already been caught sneaking firearms onto Holloman Air Force Base" in New Mexico, and said that he had concocted a plan to use a bus to escape the mental health facility.

El Paso police quickly found Kelly in the city and said he "did not resist or make any comments about harming himself or others to the officers."

Kelley would later plead guilty to assaulting his wife and stepson. He spent a year in a military brig and received a bad conduct discharge from the Air Force in 2014.

The Air Force confirmed Monday that it failed to transmit records of Kelley's conviction to an FBI database used to perform background checks for gun purchases, and officials ordered an internal review of the case and Air Force policies.

The rape accusation stemmed from a report on June 17, 2013, while Kelley was living in New Braunfels, Texas. The Comal County Sheriff's Office did not give more details about the case, which "stalled sometime in October 2013 for reasons yet to be determined," the office said in a statement.

It is not clear whether Kelley was arrested in that case, or whether any criminal charges were filed.

On Tuesday, the Comal County criminal district attorney's office wrote a letter to the Texas attorney general's office requesting a legal opinion over whether certain records involving the rape case could be released, citing the victim's privacy.

The sheriff's office also said that deputies went to Kelley's residence on Feb. 1, 2014, after receiving a call "from a female saying that her boyfriend was abusing her," according to department incident dispatch logs. According to those reports, the woman told police "her arms were red and he told her to pack a bag."

The deputies made no arrests, dismissing the call as "misunderstanding and teenage drama."

Kelley subsequently moved to Colorado, and was cited for misdemeanor animal abuse in a Colorado Springs trailer park on Aug. 1, 2014.

Investigators believe Kelley acted alone in the church attack and was not motivated by any political or religious agenda, but perhaps by a domestic argument Kelley had with his mother-in-law, who is a member of the church's congregation but who was not in attendance during the attack.

Officials on Tuesday praised Stephen Willeford, a church neighbor who shot Kelley in the leg and the torso and pursued him out of town, calling him a "hero."

"How can you not love that guy?" said Texas Department of Public Safety Regional Director Freeman Martin. "That guy did what he knew needed to be done."

Ten victims remained in critical condition Tuesday.