Meredith Cooper, of San Antonio, Texas, and her 8-year-old daughter, Heather, visit a memorial of 26 metal crosses near First Baptist Church in Sutherland Springs, Texas, Monday Nov. 6, 2017. The gunman of a deadly shooting at the small-town Texas church had a history of domestic violence and sent threatening text messages to his mother-in-law, a member of First Baptist, before the attack, authorities said Monday. (Jay Janner/Austin American-Statesman via AP)
Meredith Cooper, of San Antonio, Texas, and her 8-year-old daughter, Heather, visit a memorial of 26 metal crosses near First Baptist Church in Sutherland Springs, Texas, Monday Nov. 6, 2017. The gunman of a deadly shooting at the small-town Texas church had a history of domestic violence and sent threatening text messages to his mother-in-law, a member of First Baptist, before the attack, authorities said Monday. (Jay Janner/Austin American-Statesman via AP) Credit: Jay Janner

Sutherland Springs, Texas — The gunman who carried out the massacre at a small-town Texas church briefly escaped from a mental health center in New Mexico in 2012 and got in trouble for bringing guns onto a military base and threatening his superiors there, police reports indicate.

Devin Patrick Kelley also was named as a suspect in a 2013 sexual assault in his Texas hometown of New Braunfels, about 35 miles from the scene of the church attack.

The records that emerged on Tuesday add up to at least three missed opportunities that might have offered law enforcement a way to stop Kelley from having access to guns long before he slaughtered much of the congregation in the middle of a Sunday service. Authorities said the death toll of 26 included the unborn baby of one of the women killed. Kelley died of a self-inflicted gunshot wound after he was chased by bystanders and crashed his car.

The Air Force confirmed on Tuesday that Kelley had been treated in the facility after he was placed under pretrial confinement stemming from a court-martial on charges that he assaulted his then-wife and hit her child hard enough to fracture the boy’s skull.

Involuntary commitment to a mental institution would have been grounds to deny him a weapon provided that records of his confinement were submitted to the federal database used to conduct background checks on people who try to buy guns.

Kelley also was caught trying to bring guns onto Holloman Air Force Base in New Mexico when he was stationed there, according to an El Paso, Texas, police report released on Tuesday.

While in the military, Kelley, who was 21 at the time, made death threats against superior officers, according to the June 2012 report, which also mentioned the military charges. He was eventually sentenced to 12 months of confinement for the assault.

The Air Force acknowledged on Monday that it did not enter Kelley’s criminal history into the federal database as required by military rules, another way he could have been denied a weapon.

Had Kelley been convicted of sexual assault, he likely would have been prevented from purchasing a gun because federal guidelines prohibit sales to anyone convicted of a felony punishable by more than one year in prison. The Comal County sheriff said he was reviewing whether his department mishandled the sexual assault investigation.

Authorities recovered a Ruger AR-556 rifle at the church and two handguns from the shooter’s vehicle. All three weapons were purchased by Kelley, said Fred Milanowski, the agent in charge of the Bureau of Alcohol, Tobacco, Firearms and Explosives in Houston.

The El Paso report notes that Kelley was committed to a mental health facility in Santa Teresa, N.M., but at some point escaped and later was found by police at a bus station in downtown El Paso in June 2012.

Deputies were called to Kelley’s home in New Braunfels in June 2013 about the rape case and investigated for three months, Comal County Sheriff Mark Reynolds said. But it appeared that they stopped investigating after they believed Kelley left Texas and moved to Colorado. Reynolds said the case was then listed as inactive.

The sheriff said he was trying to determine how deputies came to believe Kelley had moved and why they did not continue to pursue the case, either in Colorado or after Kelley returned to the area later.