A connection has emerged between the gunman and a Texas church where 26 people were killed as police described the victims as “defenceless people”.

A gunman dressed in black tactical-style gear and armed with an assault rifle opened fire inside the small church before killing people aged between five and 72 in the state’s worst ever such atrocity.

Once the shooting started on Sunday at the First Baptist Church in Sutherland Springs, there was probably “no way” for congregants to escape, said Wilson County Sheriff Joe D Tackitt Jr.

About 20 others were wounded.

“He just walked down the centre aisle, turned around and my understanding was shooting on his way back out,” said Mr Tackitt, who said the gunman also carried a handgun but that he did not know if it was fired.

Mr Tackitt described the scene as “terrible.”

“It’s unbelievable to see children, men and women, laying there. Defenceless people,” he said.

Mr Tackitt told CNN the gunman’s former in-laws attended services at the church “from time to time” but were not in attendance on Sunday.

The gunman has been identified by officials as Devin Kelley.

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

The gunman crossed the street and started firing the rifle at the church, said Freeman Martin, a regional director of the Texas Department of Safety, then continued firing after entering the white wood-frame building, where an 11am service was scheduled.

As he left, the gunman was confronted by an armed resident who “grabbed his rifle and engaged that suspect”, Mr Martin said.

A short time later, the suspect was found dead in his vehicle at the county border.

Federal agents, including ATF investigators and the FBI’s evidence collection team, swarmed the small rural community of just hundreds of residents.

Several weapons were found inside the vehicle and Mr Martin said it was unclear if the attacker died of a self-inflicted wound or if he was shot by the resident who confronted him.

Mr Martin said 23 of the dead were found in the church, two were found outside and one died after being taken to a hospital.

The man who confronted Kelley had help from another local resident, Johnnie Langendorff, who told KSAT TV that he was driving past the church as the shooting happened.

Among those killed was the church pastor’s 14-year-old daughter, Annabelle Pomeroy.

Pastor Frank Pomeroy and his wife, Sherri, were both out of town when the attack occurred, Sherri Pomeroy wrote in a text message.

“We lost our 14-year-old daughter today and many friends,” she wrote.

“Neither of us has made it back into town yet to personally see the devastation.

“I am at the Charlotte airport trying to get home as soon as I can.”

Church member Nick Uhlig, 34, who was not at Sunday’s service, said his cousin, who was eight months pregnant, and her in-laws were among those killed.

He later told the Houston Chronicle three of his cousin’s children also were killed.

Mass shootings(PA Graphics)

President Donald Trump, who was in Japan, called the shooting an “act of evil”, later calling the gunman “a very deranged individual”.

Two sheriff’s vans were parked outside the gate of a cattle fence surrounding the address listed for Kelley on the rural, western outskirts of New Braunfels, north of San Antonio.

Ryan Albers, 16, who lives across the road, said he heard intensifying gunfire coming from that direction in recent days.

“It was definitely not just a shotgun or someone hunting,” Ryan said.

“It was someone using automatic weapon fire.”

The church has posted videos of its Sunday services on a YouTube channel, raising the possibility that the shooting was captured on video.

Texas governor Greg Abbott said the attack was the worst mass shooting in Texas history.

It came on the eighth anniversary of a shooting at Texas’ Fort Hood, where 13 people were killed and 31 others wounded by a former US Army major.

The previous deadliest mass shooting in Texas had been a 1991 attack in Killeen, when a mentally disturbed man crashed his pickup vehicle through a restaurant window at lunchtime and started shooting people, killing 23 and injuring more than 20 others.

The University of Texas was the site of one of the most infamous mass shootings in modern American history, when US Marine sniper Charles Whitman climbed the Austin campus’ clock tower in 1966 and began firing on stunned people below, killing 13 and wounding nearly three dozen others.

He had killed his wife and mother before heading to the tower, one victim died a week later and medical examiners eventually attributed a 17th death to Whitman in 2001.