(CNN) A gunman killed 26 people and wounded 20 others at a Texas church Sunday morning in what Gov. Greg Abbott called the largest mass shooting in state history.

At one point, the shooter tried to get a license to carry a gun in Texas but was denied by the state, Abbott said, citing the director of Texas' Department of Public Safety.

"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," Abbott told CNN. "So how did this happen?"

How the attack unfolded

Around 11:30 a.m. local time, a man dressed in all black exited a vehicle and started firing a rifle outside First Baptist Church in Sutherland Springs , a Texas community of a few hundred people about 30 miles east of San Antonio, the Texas Department of Public Safety said.

The gunman then entered the church, where services were underway, and continued to fire, officials said.

Photos: Sutherland Springs church shooting Investigators work at the scene of a mass shooting at the First Baptist Church in Sutherland Springs, Texas, on Sunday, November 5. A man opened fire inside the small community church, killing at least 26 people. Hide Caption 1 of 15 Photos: Sutherland Springs church shooting People comfort each other at a community center near the scene of the deadly shooting. Hide Caption 2 of 15 Photos: Sutherland Springs church shooting Investigators work at the scene. Victims range in age from 17 months to 77 years old.

Hide Caption 3 of 15 Photos: Sutherland Springs church shooting Enrique and Gabby Garcia watch investigators at the scene. Hide Caption 4 of 15 Photos: Sutherland Springs church shooting Law enforcement officials gather near the First Baptist Church. The shooter was killed after a brief chase north into neighboring Guadalupe County, according Guadalupe County Sheriff's Office spokesman Robert Murphy. Hide Caption 5 of 15 Photos: Sutherland Springs church shooting A man wipes his eyes after the shooting. Hide Caption 6 of 15 Photos: Sutherland Springs church shooting Flags are lowered to half staff at First Baptist Church following the shooting. Hide Caption 7 of 15 Photos: Sutherland Springs church shooting Law enforcement officials and forensic experts gather at the scene. Hide Caption 8 of 15 Photos: Sutherland Springs church shooting Emergency personnel seal off the scene of the mass shooting. Hide Caption 9 of 15 Photos: Sutherland Springs church shooting Law enforcement officers man a barricade near the church. Hide Caption 10 of 15 Photos: Sutherland Springs church shooting Carrie Matula embraces a woman after the shooting. Matula said she heard the shooting from the gas station where she works across the street. Hide Caption 11 of 15 Photos: Sutherland Springs church shooting Law enforcement officials work the shooting scene. Hide Caption 12 of 15 Photos: Sutherland Springs church shooting A woman prays with a man after the shooting. Hide Caption 13 of 15 Photos: Sutherland Springs church shooting The FBI responded to the scene of the shooting, according to Michelle Lee, spokeswoman for the FBI's San Antonio field office. Hide Caption 14 of 15 Photos: Sutherland Springs church shooting "My heart is broken," said Wilson County Commissioner Albert Gamez Jr. "We never think where it can happen, and it does happen. It doesn't matter where you're at. In a small community, real quiet and everything, and look at this, what can happen." Hide Caption 15 of 15

Martin said there was an exchange of gunfire and the killer dropped his gun -- a Ruger AR "assault-type rifle" -- and sped away in a Ford Explorer. The armed resident, Stephen Willeford, hailed a man who was driving by and they pursued the shooter in a high-speed chase.

The gunman drove north into neighboring Guadalupe County, authorities said. Just across the county line, law enforcement officers found him dead inside his vehicle with gunshot wounds, Martin said.

Martin said an autopsy showed the shooter had three gunshot wounds: one in the leg and one in the torso from the armed citizen and a third in the head that "the medical examiner described as being consistent with being self-inflicted."

The shooter and the investigation

The church attacker was identified as 26-year-old Devin Patrick Kelley of New Braunfels, Texas.

Sutherland Springs shooting suspect -- Devin Patrick Kelley, 26, of New Braunfels, TX -- is pictured here in his driver license photo. pic.twitter.com/yDPKOfh2OM — Texas DPS (@TxDPS) November 6, 2017

Martin said Kelley dressed in all-black "tactical-type gear" and was wearing a ballistic vest.

Kelley had been armed with two weapons, a rifle and a handgun, Wilson County Sheriff Joe Tackitt said. But the sheriff said he did not know if the handgun was used inside the church. Investigators found 15 empty magazines for the rifle, each capable of holding 30 rounds, inside the church, authorities said.

Investigators found indications in Kelley's social media presence that he was interested in mass shootings, said a law enforcement official. Investigators pieced together from social media and interviews that Kelley had become increasingly obsessed over an unspecified family dispute.

Authorities said he sent threatening texts as recently as Sunday morning to his mother-in-law.

Kelley was a former member of the US Air Force. He served in logistics readiness at Holloman Air Force Base in New Mexico starting in 2010, according to Air Force spokeswoman Ann Stefanek.

Kelley was charged in military court in 2012 on suspicion of assaulting his spouse and their child, Stefanek said. Kelley received a bad conduct discharge, confinement for 12 months, and was demoted to E-1, or airman basic, she said.

The US Air Force acknowledged Kelley's court martial conviction was not entered into the federal law enforcement database at the National Criminal Information Center, information that might have prevented gun sales to Kelley. Federal law prohibits people convicted of a misdemeanor crime involving domestic violence from owning firearms.

Kelley purchased the gun he used in the church shooting, a Ruger AR-556 rifle, in April 2016 from an Academy Sports + Outdoors store in San Antonio, a law enforcement official told CNN. He listed an address in Colorado Springs, Colorado, when he bought the rifle, the official said.

When Kelley filled out background-check paperwork at the store, he checked a box to indicate he didn't have any disqualifying criminal history, the official said.

There was no disqualifying information in his background check, a law enforcement official told CNN.

The victims

Of the 26 who died, 23 were found dead inside the church. Two bodies were found outside. One person died after being transported to a hospital, Martin said.

JUST WATCHED Commissioner: Gunman fled in vehicle Replay More Videos ... MUST WATCH Commissioner: Gunman fled in vehicle 01:06

Pastor Frank Pomeroy was out of town when the shooting occurred, but his daughter, 14-year-old Annabelle , was killed at the church, her mother Sherri Pomeroy said.

Texas shooting victim Annabelle Pomeroy

"We lost more than Belle yesterday, and the one thing that gives me a sliver of encouragement is the fact that Belle was surrounded by her church family that she loved fiercely and vice versa," Sherri Pomeroy said.

Eight members of one family , including a pregnant woman and a 17-month-old girl, were among the dead. The eight included the visiting pastor, Bryan Holcombe, and members of his family, said Ron Scott, the visiting pastor's first cousin.

The shooter's grandmother-in-law, Lula White, also was killed.

Many of the victims have not been publicly identified, but family members have come forward with details and photos of their slain loved ones. The dead ranged in age from 17 months to 77 years old, Martin said.

About 20 people were taken to hospitals with injuries ranging from minor to severe, authorities said.

Reaction

JUST WATCHED Trump offers his support after church shooting Replay More Videos ... MUST WATCH Trump offers his support after church shooting 01:03

The President, who was in Japan, said the shooting was caused by a "mental health problem," not an issue with gun laws.

"Mental health is your problem here," Trump said, noting that "based on preliminary reports" the shooter was "a very deranged individual."

"This isn't a guns situation," Trump said. "This is a mental health problem at the highest level. It's a very, very sad event."

May God be w/ the people of Sutherland Springs, Texas. The FBI & law enforcement are on the scene. I am monitoring the situation from Japan. — Donald J. Trump (@realDonaldTrump) November 5, 2017

Abbott, Texas' governor, said the state would mourn the dead and support their families. Vice President Mike Pence and his wife will visit Sutherland Springs on Wednesday.

"As governor, I ask for every mom and dad at home tonight, that you put your arm around your kid and give your kid a big hug, and let them know how much you love them," Abbott said at a news conference Sunday evening.