The attack happened at the First Baptist Church in Sutherland Springs, a small town in Wilson County. The victims’ ages ranged from five to 72.
The suspected gunman was later found dead in his vehicle some miles away.
Police identified him only as a “young, white male”, but US media named him as Devin Patrick Kelley, 26.
Kelley is reported to have been discharged from the US Air Force in 2014 following a court-martial for assaulting his wife and child.
The motive for the killings is not yet clear.
Texas Department of Public Safety regional director Freeman Martin said the attacker, dressed all in black and wearing a bulletproof vest, opened fire with an assault-style rifle outside the church at around 11:30 local time (17:30 GMT) and then went inside.
As the gunman left the church, a local citizen grabbed his own rifle and began shooting at the suspect, who then dropped his weapon and fled in a vehicle.
The citizen pursued the suspect, who eventually drove off the road and crashed his car at the Guadalupe County line.
Police found the man dead in his car, but it is unclear if he died from a self-inflicted gunshot wound or from injuries received when fired on by the local citizen. The car contained several weapons.
Mr Martin added: “We have multiple crime scenes. We have the church, outside the church. We have where the suspect’s vehicle was located.
“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.”
Governor Greg Abbott, confirming the death toll, said it was the worst mass shooting in the history of Texas.
“This will be a long, suffering mourning for those in pain,” he said at a news conference on Sunday.
The First Baptist Church’s pastor, Frank Pomeroy, told ABC News that his 14-year-old daughter, Annabelle, was among those killed.
Mr Pomeroy, who was in Oklahoma at the time of the attack, described her as “one very beautiful, special child” in a phone call to the television outlet.
At least 10 victims, including four children, were being treated at the University Health System in nearby San Antonio, the hospital said in a tweet.
Sheriff Joe Tackitt said authorities could not confirm the names of any victims yet as they continued to work through the crime scene.
Officials said 23 people were found dead inside the church while two people were fatally shot outside. Another died in hospital, authorities said.
One witness, Carrie Matula, told NBC News: “We heard semi-automatic gunfire… we’re only about 50 yards away from this church.
“This is a very small community, so everyone was very curious as to what was going on.”
Sutherland Springs, which has a population of about 400, lies about 30 miles (50km) south-east of the city of San Antonio.
President Donald Trump, on a tour of Asia, condemned the “act of evil” and said Americans would pull together.
“And through the tears and through the sadness, we stand strong, oh so strong,” he added.
The shooting comes just a month after a gunman in Las Vegas opened fire on an outdoor music festival, killing 58 people and wounding hundreds in the deadliest mass shooting in recent US history.
This story was originally published in bbc.com