Devin Patrick Kelley, 26, was identified by authorities as the gunman who killed more than two dozen people in a hail of gunfire at a rural Texas church on Sunday.
Law enforcement officials identified Kelley, who was killed following the incident at First Baptist Church in Sutherland Springs, hours after news of the shooting first broke. Dozens were left wounded, and The Associated Press reported that the church's pastor and his wife lost their teenage daughter in the massacre.
According to authorities, Kelley is from the neighboring Comal County.
Sunday's shooting was the largest mass killing in a place of worship in U.S. history, according to NBC News.
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.