Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

The gunman who turned a Texas church into a shooting gallery had a turbulent and violent past, including a court-martial from the Air Force for fracturing his baby stepson's skull, an animal cruelty arrest — and a habit of harassing ex-girlfriends.

"He was very sick in the head," Katy Landry, a former girlfriend of Devin Patrick Kelley, told NBC News.

Kelley, 26, arrived at the First Baptist Church in Sutherland Springs on Sunday ready for war, wearing black tactical gear and a ballistics vest and toting what authorities described as an "assault-type rifle." He opened fire, killing 26 people, at least a dozen of them children.

What was behind this act of carnage in a place of sanctuary? Authorities have not specified a motive but they noted that his mother-in-law had attended the church and been threatened by him.

Dave Ivey, Kelley's uncle, said in a Facebook message that he "never in a million years could of believed Devin could be capable of this kind of thing."

Related: Texas Church Shooter Had Threatened Mother-in-Law

"I am numb," Ivey said. "My family will suffer because of his coward actions. ... I am so sorry for the victims in Texas."

Details of Kelley's life, however, painted a portrait of a young man capable of disturbing behavior.

Air Force spokeswoman Ann Stefanek confirmed that Kelley — who joined the military after graduating from New Braunfels High School in 2009 — was court-martialed in 2012 on two charges of assault.

Devin Kelley in an undated driver's license photo. Texas Department of Public Safety

A retired Air Force colonel who supervised prosecutors when Kelley was brought before the court-martial said Kelley was convicted of fracturing his baby stepson's skull and assaulting his first wife, Tessa, in the incident at Holloman Air Force Base in New Mexico.

He was confined for a year, given a bad conduct discharge and reduced in rank to E-1, or airman basic, Stefanek said. The military failed to enter the domestic violence case into a database that would have made it illegal for him to buy a gun, officials said.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Records show his first wife divorced him in 2012 in New Mexico. "She's very upset," her mother told NBC News, adding that she did not want to speak about him until she was interviewed by law enforcement.

Kelley remarried in Texas in 2014. The status of that marriage was not clear, but authorities said there was a "domestic situation" with his in-laws.

"The suspect's mother-in-law attended this church," Freeman Martin, regional director of the state Department of Public Safety, said at a Monday news conference. "She has received threatening texts from him."

Related: About Half of the Texas Church Victims Were Children

Two ex-girlfriends told NBC News that Kelley stalked them after breakups.

"Years after dating me he would try to bribe me to hang out with him," Landry, who met Kelley in church as a teenager, told NBC News in a Facebook message. "He ended up assaulting me. He would stalk me by repeatedly calling me — even prank calling me, saying really weird stuff.

"That was another thing about him — he was very sick in the head...He would tell me very sick strange things," she said, without providing details.

Brittany Adcock, 22, said she dated Kelley for two months when she was 13 and he was 18.

"At the time I didn't think much into it being so young but now I realize that there's something off about someone who is 18 with someone who is 13," she said.

When she broke it off, he continued to harass her, she said.

"He somehow would always find out my number although none of my friends talked to him and he would constantly call me until I blocked his number," she said. "Then I'd get calls from an unknown number so I've had to change my number quite a bit.

"He would offer me money to hang out with him quite a bit. There has been one point that I called the police because he was just calling me so much I wanted to report harassment," Adcock said.

"One time he told me I should move in with him and his wife and that he would take care of me as long as I walked around topless. Not long after, his wife messaged me and asked why I'm talking to her husband and I told her what he was saying and sent her screenshots and she then apologized and then I was blocked from speaking to her."

Devin P. Kelley in freshman year at New Braunfels High School, New Braunfels, Texas in 2006. Seth Poppel/Yearbook Library

A search of criminal records in Comal County, where Kelley lived, yielded only minor violations — driving with an expired registration, speeding, failure to stop at a stop sign, driving without insurance.

But in Colorado Springs, Colorado, where Kelley lived for a short time, he was arrested in 2014 on an animal cruelty charge, according to police records.

Witnesses to that incident told investigators that they saw Kelley chasing the dog at a trailer park and attacking the animal when he caught it.

"The suspect then started beating on the dog with both fists, punching it in the head and chest," the police report said, citing a witness. "He could hear the suspect yelling at the dog and while he was striking it, the dog was yelping and whining. The suspect then picked up the dog by the neck into the air and threw it onto the ground and then drug him away to lot 60."

Court records show that Kelley, who told police he was trying to stop the dog from attacking another animal, paid a fine in the case.

As Sutherland Springs mourned its dead, investigators were trying to piece together a portrait of the gunman and determine the motive. Federal officials said they'd found no obvious link between Kelley and an organized terrorist group, and state police said there was no evidence of a racial of religious motivation.

Martin told reporters that Kelley was wearing the tactical gear and the ballistics vest when he pulled into a gas station in Sutherland Springs at 11:20 a.m. (12:20 p.m. ET) Sunday. He had multiple weapons in his car, Martin said.

After leaving the gas station, the gunman crossed the street, got out of his car and sprayed First Baptist Church's right side with his rifle, Martin said.

He then entered the church and continued to fire until a local resident grabbed his own rifle and fired at Kelley, forcing him to drop his weapon and flee. The resident pursued Kelley, who drove off the road and crashed, Martin said.

Kelley was later found dead, Martin said, although it was unclear how he died.

"The cause and manner of the death...will be determined by a pathologist during the autopsy," Martin said. "However, investigators found evidence at the scene that indicates the subject may have died from a self-inflicted gunshot wound."