A Texas sporting goods store broke the law when it sold an AR-15-style rifle and large-capacity magazine to a man who later committed a mass murder at a San Antonio-area church, federal prosecutors argued in a court filing.

Devin Patrick Kelley, who fatally shot himself as authorities chased him following the bloody massacre at First Baptist Church in Sutherland Springs in 2017, was ineligible to make the purchase because he used a Colorado driver’s license as identification, prosecutor Paul David Stern wrote.

SUPREME COURT SEEMS SPLIT ON DC SNIPER LEE BOYD MALVO'S POTENTIAL RESENTENCING

“Sale of that rifle would have been illegal in Colorado,” Stern wrote, referring to a Model 8500 Ruger AR-556 that authorities say Kelley bought from Academy Sports + Outdoors.

In 2017, Texas Gov. Greg Abbott said the state had denied Kelley a gun permit and he should not have been legally allowed to own a firearm, the BBC reported.

Kelley fired at least 450 rounds inside the church, killing more than two dozen people and wounding 20 more, authorities have said. A nearby resident shot and wounded Kelley before the killer drove away and ultimately ended his own life, according to authorities.

Now federal authorities are looking to add the Texas retailer as a possible third party in a lawsuit that relatives of those killed or wounded in the massacre have filed against the federal government. The plaintiffs argue that the U.S. Air Force neglected to add Kelley’s criminal data to a national database that might have blocked his weapons purchase, despite six opportunities to add the information.

Kelley, a former airman, had a background that included beating his wife and stepson, mistreating animals, escaping a mental health clinic and being court-martialed, the BBC reported.

The Justice Department argued that federal employees should be shielded from the legal action, but in May U.S. District Judge Xavier Rodriguez in San Antonio ruled that the government itself should not be shielded.

CLICK HERE TO GET THE FOX NEWS APP

Academy Sports + Outdoors operates more than 250 stores in 16 states and posted $4.9 billion in sales for the fiscal year that ended in February, a company spokeswoman told the Associated Press. She would not comment on the federal court filing, the AP added.

Jamal Alsaffar, an attorney representing the victims’ families, said the plaintiffs expect federal authorities to examine Academy’s history of gun sales for examples of firearms sales that should have been prohibited.

The Associated Press contributed to this story.