The Air Force failed repeatedly to report information that could have stopped Devin Patrick Kelley, a former U.S. airman who killed 26 people in a church in Texas, from buying a gun.

That’s according to a Department of Defense inspector general’s report released Friday.

While in the Air Force, Kelley was convicted by a general court-martial on two charges of domestic assault against his then-wife and stepson. He was released with a bad conduct discharge in 2014.

Three years later, Kelley opened fire on the First Baptist Church in Sutherland Springs. He was armed with weapons he bought legally ― despite his history of domestic violence, which should have blocked him from passing a background check.

Under federal law, convicted domestic abusers can’t buy or possess firearms.

Almost immediately, the Air Force admitted that it had not submitted Kelley’s criminal history information to the FBI database used to determine if an individual can legally buy a gun, called the National Instant Criminal Background Check System, or NICS. The Air Force’s admission led to a new law that aims to close loopholes in the system.

Friday’s report is the first to fully detail what went wrong in Kelley’s case.

ASSOCIATED PRESS Devin Patrick Kelley killed 26 people and injured 20 others in Sutherland Springs, Texas, before dying from a self-inflicted gunshot wound.

Kelley enlisted in the Air Force in 2010, and in 2011, he married Tessa Kelley.

He became extremely abusive, she later told investigators, strangling her, kicking her in the stomach, dragging her by her hair, and occasionally sticking her head under the shower to “water-board” her. Her minor son was also a target of Kelley’s wrath and was hospitalized more than once due to Kelley’s violence.

She reported him to officials, and in November 2012, Kelley pleaded guilty in general court-martial proceedings to assault on his then-wife and stepson. He was sentenced to a reduction in rank, confinement for 12 months and a bad conduct discharge.

Under Department of Defense policy, investigators were required to submit Kelley’s fingerprints to the FBI. The report counts four missed opportunities in which his fingerprints should have been sent and weren’t. The Air Force also missed opportunities to submit its final report on the case to the FBI ― twice. That’s six failures in all.

If the Air Force had passed along Kelley’s information, he would have been banned from purchasing guns.

Instead, Kelley was able to buy four guns after leaving the Air Force, three of which he carried with him into the First Baptist Church in Sutherland Springs on Nov. 5, 2017.

Kelley married a woman named Danielle Kelley after leaving the Air Force, and it appears he was targeting the church where his mother-in-law, Michelle Shields, worshipped.

Shields has said Kelley threatened her over text and was possessive and abusive toward her daughter. Kelley’s mother-in-law was not at church, but his wife’s grandmother was among his victims. Before beginning his bloody rampage that morning, Kelley tied his wife to their bed.

After killing 26 and injuring 20 others, Kelley fled the church and later died from a self-inflicted gunshot wound.

Kelley is among the many, many, many mass shooters with a history of domestic violence.

In fact, over half of all mass shootings in the U.S. ― incidents in which more than four people are fatally shot ― involve a perpetrator targeting an intimate partner or family member.

Need help? In the U.S., call 1-800-799-SAFE (7233) for the National Domestic Violence Hotline.