A federal judge ruled that the U.S. Air Force bears most of the responsibility for the 2017 mass shooting at a church in Sutherland Springs, Texas, because it failed to enter the shooter’s criminal history into a federal background check database used for gun purchases.

The decision Wednesday from U.S. District Judge Xavier Rodriguez of the Western District of Texas comes in a civil lawsuit brought by survivors and families of victims of the massacre at the First Baptist Church in Sutherland Springs, which left 26 people dead. The 26-year-old gunman, former Airman Devin Kelley, killed himself shortly after the attack, the deadliest mass shooting in Texas history.

In his decision, Judge Rodriguez said the Air Force bore 60% of the responsibility for the shooting and ordered parties to set a trial plan within 15 days to assess monetary damages for the survivors and victims’ families in the case.

“The trial conclusively established that no other individual—not even Kelley’s own parents or partners—knew as much as the United States about the violence that Devin Kelley had threatened to commit and was capable of committing,” the judge wrote. “Moreover, the evidence shows that—had the Government done its job and properly reported Kelleys information into the background check system—it is more likely than not Kelley would have been deterred from carrying out the Church shooting.”

Kelley had been convicted in a 2012 general court-martial on two counts of domestic assault on his wife and their child and sentenced to a year in military jail, which should have barred him from legally buying a gun. But the Air Force never entered his conviction into the National Instant Criminal Background Check System, which gun dealers must use to check for criminal records before selling someone a firearm. As a result, after being thrown out of the military, Kelley was able to purchase a rifle at a gun store, which he later used in the Sutherland Springs shooting.

Federal law bars people with felony convictions, which Kelley’s military case is considered, from owning guns.

Victims’ families alleged in the suit that the Air Force’s failure to enter Kelley’s court-martial conviction into the NICS database made it liable for the attack. At the weekslong trial earlier this year, the Air Force admitted that it failed to enter Kelley’s criminal history into the database but argued that Kelley was so bent on violence he would have found a way to buy guns anyway.

Experts on gun laws said the case was particularly notable because it highlighted serious flaws in the background check system for gun purchases.

From the Archives

Multiple people were killed after a shooter opened fire at a Baptist church in Sutherland Springs, Texas. Photo: Nick Wagner/Austin American-Statesman/AP (Video from 11/5/17) The Wall Street Journal Interactive Edition