The gunman who opened fire at a Texas church and killed at least 26 people posted a photo of a semiautomatic rifle on Facebook alongside the caption “she’s a bad b****” a week before the mass shooting.

The suspect, named as 26-year-old Devin Patrick Kelley, walked into a church in a small town near San Antonio on Sunday and left at least 26 people between the ages of five and 72 dead and wounded 20 more.

A law enforcement source close to the investigation told The Daily Beast the rifle Mr Kelley used is similar to the one in the photo but could not confirm it is the same weapon.

The weekly service at the First Baptist Church in Sutherland Springs started at 11am, with the congregation waiting to hear a sermon around the time Mr Kelley arrived. Officials said the gunman wore a ballistic vest and came dressed in all black.

Police said the assailant crossed the street in his vehicle, got out and began firing using a Ruger AR assault-type rifle. He then moved to the right side of the church, continuing to fire and then into the building - still firing bullets - before later being found dead in a neighbouring county.

A US official told The Associated Press that Kelley lived in a San Antonio suburb and that he does not appear to be linked to organised terrorist groups. They said investigators are looking at social media posts Kelley may have made in the days leading up to the mass shooting, including one that appeared to show an AR-15 style semi-automatic weapon.

Neighbours of an address listed for Mr Kelley have said they heard intense gunfire from the direction of the house in the last few days.

"It's really loud," said Ryan Alberts, 16, who lives across the road. "At first I thought someone was blasting."

(Facebook)

He added: "It was someone using automatic weapon fire."

A US Air Office official said Mr Kelley was a former serviceman. He served in logistics readiness at Holloman Air Force Base in New Mexico from 2010 before being court-martialled in 2012 and dishonourably discharged two years later.

Spokeswoman Ann Stefanek said Mr Kelley was court-martialled on one count of assaulting his wife and another count of assault on their child. He received a bad conduct discharge, 12 months confinement and a reduction in rank.

Donald Trump has said the worst mass shooting in the modern history of Texas and the worst massacre at a place of worship in American history is not "a guns situation".

Asked at a press conference in Tokyo what policies he might support in response to the killing spree, President Trump, who received millions of dollars for his 2016 presidential campaign from the National Rifle Association, said preliminary reports suggested the gunman was "a very deranged individual, [with] a lot of problems."

"We have a lot of mental health problems in our country, as do other countries. But this isn't a guns situation," he said. "Fortunately somebody else had a gun that was shooting in the opposite direction."

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

He added: "This is a mental health problem at the highest level. It's a very, very sad event."

Authorities have not yet determined Kelley's motive and have not mentioned the issue of the alleged gunman’s mental health.