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.”