Donald Trump has said the mass shooting at a Texas church “isn’t a guns situation”, but is a “mental health problem at the highest level”.

The president spoke after a man killed 26 people and wounded at least 16 others in what the governor called the deadliest mass shooting in the state’s history.

Devin Kelley, the man authorities have identified as the gunman, was discharged from the Air Force several years ago for allegedly assaulting his spouse and a child.

While no officials have publicly questioned Kelley’s mental health, Mr Trump said that “is your problem here” when asked about the shooting as he and Japanese Prime Minister Shinzo Abe held a joint news conference in Tokyo.

“This was a very, based on preliminary reports, a very deranged individual. A lot of problems over a long period of time,” Mr Trump said.

Texas church shootingMourners participate in a candlelight vigil for the victims of the fatal shooting (Darren Abate/AP)

“We have a lot of mental health problems in our country, as do other countries. But this isn’t a guns situation,” the president said.

The attack happened on Sunday morning when a man dressed in black tactical-style gear and armed with an assault rifle opened fire inside a Baptist church in a small South Texas community.

Mr Trump first tweeted that he was monitoring the situation from Japan.

He later described the shooting as an “act of evil” during remarks to a gathering of American and Japanese business executives.

Air Force spokeswoman Ann Stefanek said that Kelley served 12 months’ confinement after a 2012 court-martial. He ultimately received a bad conduct discharge and reduction in rank.

She said Kelley served in Logistics Readiness at Holloman Air Force Base in New Mexico from 2010 until his discharge in 2014.

He was responsible for moving passengers, cargo and personal property in military transportation.

As Kelley left the scene, authorities said he was confronted by an armed resident who engaged the suspect, who was later found dead in his vehicle.

Mass shootings(PA Graphics)

Mr Trump said “fortunately somebody else had a gun that was shooting in the opposite direction otherwise it (wouldn’t) have been as bad as it was, it would have been much worse”.

He added: “But this is a mental health problem at the highest level. It’s a very, very sad event.”

The shooting comes just over a month after a gunman opened fire on an outdoor music festival on the Las Vegas Strip from the 32nd floor of a hotel-casino, killing 58 people and wounding more than 500.

Mr Trump visited Las Vegas soon after to meet families of victims and the emergency services.

In the days after the Las Vegas shooting, Mr Trump and his aides declined to discuss possible changes to gun laws, saying it was too soon after the tragedy to talk about policy.

Mr Trump on Monday ignored shouted questions about whether the US needs to consider tightening gun laws.

One US official said Kelley lived in a San Antonio suburb and did not appear to be linked to organised terrorist groups.

Investigators were looking at social media posts Kelley made in the days before Sunday's attack, including one that appeared to show an AR-15 semi-automatic weapon.

At a news conference, the attacker was described only as a white man in his 20s who pulled into a petrol station across from the First Baptist Church in Sutherland Springs, about 30 miles from San Antonio.

The gunman crossed the street and started firing a Ruger AR rifle at the church, said Freeman Martin, a regional director of the Texas Department of Safety.

He then continued firing after entering the white wood-frame building, where an 11am service was scheduled.

Wilson County Sheriff Joe D Tackitt Jr, whose territory includes Sutherland Springs, said there was probably "no way" for the church congregation to escape once the shooting started.

"He just walked down the centre aisle, turned around and my understanding was shooting on his way back out," said Mr Tackitt.

He said the gunman also carried a handgun but that he did not know if it was fired.

The sheriff described the scene as "terrible" and said: "It's unbelievable to see children, men and women, laying there. Defenceless people."

The victims included multiple family members and tight-knot neighbours ranging in age from five to 72 years old.