Authorities did not identify the gunman, saying only that he was a "young white male, maybe in his early 20s," who was wearing a bulletproof vest and found dead in his vehicle after being confronted by a local resident.
Exactly five weeks after the worst shooting in modern US history, the latest tragedy prompted an outpouring of condolences, led by US President Donald Trump.
The victims, who ranged in age from five to 72, were gunned down at First Baptist Church in Sutherland Springs, a rural community of about 400 people located 30 miles (50 kilometers) southeast of San Antonio.
The gunman fired outside at the church before entering the building and continuing to spray bullets, said Freeman Martin, regional director of the Texas Department of Public Safety.
"As he exited the church, a local resident grabbed his rifle and engaged that suspect. The suspect dropped his rifle, which was a Ruger AR assault-type rifle, and fled from the church. Our local citizen pursued the suspect at that time," Martin said.
Law enforcement later found the gunman dead in his car, which had crashed, on the Wilson-Guadalupe county line. It was not clear if he had committed suicide or was shot by the resident who had confronted him.
Multiple weapons were found in the car, which was processed by bomb technicians.
"We have multiple, multiple crime scenes. We have the church, outside the church. We have where the suspect's vehicle was located," said Martin.
"We have been following up on the suspect and where he's from. We have Texas Rangers at all the hospitals locating those and interviewing those who were injured."
US media outlets identified the shooter as a 26-year-old veteran who had faced a court-martial and was dishonorably discharged from the Air Force in 2014.
US Air Force spokeswoman Ann Stefanek told AFP that the man had served in the logistics readiness at Holloman Air Force Base, New Mexico, from 2010 until his discharge.
- Victims -
"There's so many families who have lost family members. Fathers, mothers, sons, and daughters," Governor Greg Abbott said, warning the toll could rise.
"The tragedy, of course, is worsened by the fact that it occurred in a church, a place of worship, where these people were innocently gunned down. We mourn their loss, but we support their family members."
The wounded had been transported to various hospitals with "injuries that vary from minor to very severe," Martin said.
The dead included the 14-year-old daughter of pastor Frank Pomeroy, the church leader told ABC News.
Annabelle Renee Pomeroy "was one very beautiful, special child," her father said.
Frank Pomeroy had been in the neighboring state of Oklahoma at the time of the shooting, and was driving back to Texas after the tragedy.
Other victims, some of whom were evacuated by helicopter, included a six-year-old boy named Rylan who was in surgery after being shot four times, his uncle told CBS News. A two-year-old was also shot and wounded, The Dallas Morning News reported.
A spokeswoman for Connally Memorial Medical Center in nearby Floresville said the hospital received eight patients with gunshot wounds. Four were transferred to San Antonio.
- Trump vows 'full support' -
Police formed a perimeter around the area. Tearful relatives and neighbors stood outside, nervously awaiting news from inside the traditional, white-frame church.
Agents from the FBI and the Bureau of Alcohol, Tobacco, Firearms and Explosives were headed to Sutherland Springs, the agencies said.
President Donald Trump, who is traveling in Asia, said "our hearts are broken."
"This act of evil occurred as the victims and their families were in their place of worship," he said in Tokyo.
"We pull together, we join hands, we lock arms and through the tears and through the sadness, we stand strong."
The president promised his administration's "full support" to the investigation.
As with so many other shootings before this one, Democrats pounced on the occasion to renew calls for gun control, a hot button issue in a country that holds the right to bear arms as almost sacred.
In denouncing the "act of hatred," Trump's predecessor Barack Obama said: "May God also grant all of us the wisdom to ask what concrete steps we can take to reduce the violence and weaponry in our midst."
The shooting comes just over a month after a gunman in Las Vegas fired down from a hotel room onto an outdoor concert, killing 58 people and wounding hundreds. It was the deadliest mass shooting in modern US history.
And a little more than two years ago, white supremacist Dylann Roof entered a historically black church in Charleston, South Carolina, and shot nine people to death.