The shooter who killed at least 26 people in a small church in rural Texas had previously tried to get a gun license in the state, but was denied.

“So how was it that he was able to get a gun? By all the facts that we seem to know, he was not supposed to have access to a gun,” Texas Governor Greg Abbott told CNN’s Chris Cuomo, citing the director of Texas’s Department of Public Safety. “So how did this happen?”

It wasn’t immediately clear why Devin Kelley, who was shot by an armed neighbour of the church after the massacre, was denied a firearm license. But, initial reporting suggests he had a troubled life, and had committed crimes in the past that could have conceivably barred him from legally obtaining a gun.

That includes a legal military history that got him kicked out of the United States Air Force after he was court martialed for abusing his then-wife and her child. He is said to have admitted at trial to beating his step-son so badly that his skull fractured. Kelley was sentenced to one year in military prison for those charges, and received a bad-conduct discharge from the military in 2014 after that sentence. Hi wife sued him for divorce during that sentence and it was finalised in 2012. The domestic violence conviction theoretically could have made it illegal for Kelley to own a firearm, according to a 1996 law that has since been upheld by the United States Supreme Court.

Kelley is also said to have had other run-ins with the law, and was slapped with animal cruelty charges in 2014 when he was living in Colorado. A deputy responding to 911 calls later wrote that Kelley had repeatedly punched a dog before bringing it up into the air and slamming it down onto the ground and dragging it about. During that encounter, Kelley was reportedly yelling at the animal. The dog was taken to the humane society.

According to local court records, he was given a deferred probationary sentence and ordered to pay $368 in restitution. A protection order was issued against him in January 2015, The Denver Post reported.

Kelley reportedly bought a Ruger AR-556 rifle in April of 2016 from an Academy Sports & Outdoors store in San Antonio, according to officials. When filling out the background paperwork for that weapon, the future mass-shooter ticked a box indicating that he did not have a disqualifying criminal history, and he filled in a Colorado Springs, Colorado address when asked where he lived.

Texas church shooting Show all 9 1 /9 Texas church shooting Texas church shooting The site of the mass shooting at First Baptist Church in Sutherland Springs, Texas Reuters Texas church shooting First responders are at the scene of shooting at the First Baptist Church Reuters Texas church shooting Enrique and Gabby Garcia watch investigators at the scene of the mass shooting AP Texas church shooting Law enforcement officials investigate the scene at the First Baptist Church in Sutherland Springs, Texas Reuters Texas church shooting Carrie Matula embraces a woman after a fatal shooting at the First Baptist Church in Sutherland Springs Associated Press Texas church shooting Law enforcement officials gather near the First Baptist Church Getty Images Texas church shooting Community members come together for a candlelight vigil for the victims of the deadly church shooting in Sutherland Springs Laura Skelding/AP Texas church shooting Mourners participate in the candlelight vigil held for the victims Jay Janner/Austin American-Statesman via AP Texas church shooting A vehicle is hauled onto a flatbed truck where the suspect in a deadly church shooting was found dead in Guadalupe County William Luther/Austin American-Statesman via AP

Officials did not immediately say what they believe convinced Kelley to enter the Baptist church and begin open firing, but some familial threads did begin to emerge in the day following the attack.

Kelley, who lived at his parents’ home in New Braunfels, Texas, with his second wife and child, had chosen a church where his in-laws attend services. Just one of the in-laws appears to have been in attendance during the shooting: Kelley's grandmother-in-law, who has reportedly been killed.

Kelley’s uncle expressed shock with the shooting, and said that he never would have expected that his nephew could do something like that.

“I never in a million years could of believed Devin could be capable of this kind of thing,” Dave Ivey, the uncle, told NBC News. “I am numb. My family will suffer because of his coward actions. I am so sorry for the victims in Texas.”

Still, others who knew Kelley had a different assessment of the man who made a place of sanctuary a shooting gallery on Sunday.

“He was very sick in the head,” Katy Landry, a former girlfriend of Kelley’s who met him at church, told NBC. Ms Landry, alongside other former girlfriends, described him as having habitually stalked and harassed them after their breakups.

“Years after dating me he would try to bribe me to hang out with him,” Ms Landry said. “He would stalk me by repeatedly calling me – even prank calling me, saying really weird stuff.”

The shooting began at roughly 11.20am on Sunday, just 20 minutes after the church had posted on its social media accounts that service would begin.

Kelley was seen wearing all black tactical gear including a ballistic vest at a gas station across the street from the church, before heading toward the house of worship. Outside, he began his shooting spree, before entering and continuing to shoot.

He then emerged from the church and was engaged by a man who lives nearby, and who had weapons himself. Kelley jumped into his vehicle and sped off, followed by the neighbour of the church. The chase spanned a reported 11 miles before Kelley crashed his vehicle and later died. Officials have indicated that he had two gunshot wounds, including one from the man who fought back. Kelley is thought to have also shot himself, though it is not clear if that is what killed him.