Authorities said a civilian with a gun confronted Kelley and chased him away.
The gunman fled in a vehicle after the attack and was killed, either by a self-inflicted wound or from another source.
The U.S. official said Kelley lived in a San Antonio suburb and doesn't appear to be linked to organized terrorist groups. The official said investigators are looking at social media posts Kelley may have made in the days before Sunday's attack.
While authorities provided little information about the suspect, online records show that a man named Devon Patrick Kelley lived in New Braunfels, Texas, about 35 miles (56 km) north of Sutherland Springs.
The U.S. Air Force said Kelley served in its Logistics Readiness unit at Holloman Air Force Base in New Mexico from 2010 until his 2014 discharge.
That discharge, according to a representative from the Air Force, was for bad conduct and came with confinement for 12 months and a reduction in grade.
Kelley was court-martialed in 2012 for assaulting his spouse and their child, the Air Force said.
Kelley's Facebook page has been deleted, but cached photos show a profile picture where he appeared with two small children. He also posted a photo of what appeared to be an assault rifle, writing a post that read: "she's a bad [b----]."
Kelley bought two firearms from stores operated by a sporting goods chain in 2016 and 2017 after being approved in background checks, the company, Academy Sports & Outdoors, said on Monday.
"Both sales were approved by the National Instant Criminal Background Check System (NICS). We are cooperating with law enforcement as they investigate further," privately owned Academy Sports said in a statement.
—NBC News, Reuters and The Associated Press contributed to this report.