The Texas gunman, identified as Devin Patrick Kelley, 26, fired on the church attended by his mother-in-law after he sent "threatening" text messages to her, officials have said.

Kelley - who slaughtered 26 parishioners at a church in rural Texas sent threatening text messages to his mother-in-law as a “domestic situation” roiled his extended family, Freeman Martin, a spokesman for the Texas Department of Public Safety said.

“There was a domestic situation going on within the family and the in-laws,” Mr Martin said. “The mother-in-law attended the church. We know he sent threatening ... that she had received threatening text messages from him.”

Mr Martin said that the mass shooting stemmed from this domestic situation and was not racially or religiously motivated.

Kelley, a former member of the US Air Force - was court-martialed in 2012 on charges of assaulting his wife and child and sentenced to 12 months confinement. He received a âbad conductâ discharge in 2014, according to Ann Stefanek, the chief of Air Force media operations.

The gunman walked into the white-steepled First Baptist Church in rural Sutherland Springs on Sunday carrying a Ruger AR-556 assault rifle and wearing a black bulletproof vest, then opened fire during prayer service. He wounded at least 20 others, officials said.

After he left the church, two local residents, including one who was armed, chased Kelley in a truck and they exchanged gunfire. The chase ended when Kelley crashed his car, and may have died of a self-inflicted gunshot wound or from the Good Samaritan's weapon, said Martin.

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

An autopsy will determine the cause of death, Mr Martin said.

Wilson County Sheriff Joe Tackitt said in an interview that the family members had not been present at the time of Kelley's attack

“I heard that (the in-laws) attended church from time to time,” Sheriff Tackitt said. “Not on a regular basis.”

The attack, which officials said at the press conference killed people ranging from 18 months to 77 years old, came a little more than a month after a gunman killed 58 people in Las Vegas in the deadliest shooting by a sole gunman in US history.

The initial death toll matched the fatalities at Sandy Hook Elementary School in Newtown, Connecticut, where a man shot and killed 26 children and educators and his mother before taking his own life in December 2012. Those attacks now stand as the fourth deadliest by a single gunman in the United States.

Officials warned that 10 of the wounded remained in critical condition on Monday morning.