Three cities have filed suit against the Pentagon for lapses that allowed a mass shooter in Texas to buy a gun, even though he carried a conviction in military court that should have barred his purchase.

Devin P. Kelley, who was convicted of domestic violence while serving in the U.S. Air Force, was never reported by the military for inclusion on an FBI database of individuals blocked from purchasing firearms. Kelley went on to kill more than two dozen churchgoers in Sutherland Springs, Tex., last month in one of the worst mass shootings in U.S. history.

In the complaint filed Tuesday in U.S. District Court in Alexandria, Va., the three cities — New York, San Francisco and Philadelphia — say they rely on the integrity of the FBI’s background check system. The suit alleges that the defendants, which include the military branches and Defense Secretary Jim Mattis, have an “admitted, systemic and longstanding failure to comply with the law.”

The cities are seeking to force the Defense Department to fully participate in the reporting system, which they said is already required by law. They also want the court to oversee the department’s compliance efforts.

“The Executive Branch and Congress have both had their chances to repair this clearly broken system. Now, after twenty years of failure, it’s time for the Courts to step in,” Ken Taber, a partner at Pillsbury Winthrop Shaw Pittman and lead counsel for the plaintiffs, said in a statement. The Giffords Law Center to Prevent Gun Violence also helped prepare the suit.

A spokesman for the Defense Department declined to comment Wednesday, citing a policy against commenting on ongoing litigation. A spokesman for the Justice Department said the attorney general has launched his own investigation into the issue.

“After visiting first responders and victims’ families in Sutherland Springs, Attorney General Jeff Sessions instructed the ATF and FBI to conduct a comprehensive review with the Department of Defense of how certain information is reported to the National Instant Criminal Background Check System,” Justice Department spokesman Devin O’Malley said in an email Wednesday. “The Justice Department is reviewing yesterday’s lawsuit and determining next steps.”

Members of a family ravaged by the Sutherland Springs shooting have also filed suit against the Air Force, alleging its failure to report Kelley’s criminal background led to their loved ones’ slayings.

Military officials have long acknowledged problems with the way it reports records to the FBI gun background check database.

According to Pentagon guidelines, military law enforcement personnel are supposed to submit fingerprint cards as well as information about the results of a criminal proceeding to the FBI database if troops are charged with or convicted of certain violent crimes, including domestic violence and child abuse.

However, a recent review by the Pentagon’s oversight agency, which examined 2,502 criminal cases between January 2015 and December 2016, found that 1 in 4 fingerprint cards were not submitted to the database. Military law enforcement failed to submit one-third of the final disposition reports, the review found.

Kelley’s record should have disqualified him from purchasing a weapon. Kelley spent a year in jail for crushing his young stepson’s skull, assaulting his wife and making other threats. He received a bad-conduct discharge from the military in 2014, a step below a dishonorable discharge.

Two years after his discharge, Kelley cleared a background check and bought a Ruger AR-556 semiautomatic rifle from a San Antonio sporting goods shop. The weapon was found in front of the First Baptist Church in Sutherland Springs after the Nov. 5 killings.