Three large U.S. cities filed a federal lawsuit Tuesday against the Department of Defense, arguing that many service members who are disqualified from gun ownership weren't reported to the national background check system.

New York City, San Francisco and Philadelphia said in court papers that the military's broken system for relaying such information helped spur the massacre of 26 people inside a Texas church last month.

"This failure on behalf of the Department of Defense has led to the loss of innocent lives by putting guns in the hands of criminals and those who wish to cause immeasurable harm," New York Mayor Bill de Blasio said in a statement. "New York City is joining Philadelphia and San Francisco to stand up to the Department of Defense and demand they comply with the law and repair their drastically flawed system."

Local law enforcement officials rely on the FBI's database to conduct background checks on gun permit applications and to monitor purchases. It must be up-to-date in order to prevent people from wrongly getting guns, the cities' attorneys wrote.

The lawsuit filed in federal court in Alexandria, Virginia, seeks an injunction and judicial oversight to ensure ongoing compliance with the Defense Department's obligation to submit records.

Military officials previously acknowledged problems with their reporting.

A Pentagon spokesman on Tuesday said he couldn't comment specifically on the lawsuit.

"The department continues to work with the services as they review and refine their policies and procedures to ensure qualifying criminal history information is submitted to the FBI," said Tom Crosson, a Pentagon spokesman.

The Defense Department's failure to report "significant numbers" of disqualifying records to the FBI's national background check system allowed former U.S. Air Force member Devin P. Kelley to buy a rifle and shoot 26 people to death Nov. 5 in a Sutherland Springs, Texas, church, the lawsuit said. Kelley had been convicted of assaulting family members in a 2012 court martial and should not have been allowed to purchase a gun.

Air Force leaders already acknowledged that the service failed to alert the FBI to Kelley's criminal history and that they discovered "several dozen" other such reporting omissions. They said that while policies and procedures requiring reporting were in place, training and compliance measures were lacking.

And Army leaders have said their service also has similar gaps.

Earlier this month, the Pentagon's watchdog agency it found a "troubling" number of failures this year by the military services to alert the FBI to criminal history information. Attorney General Jeff Sessions has ordered a far-ranging review of the FBI database.

Philadelphia in particular has been plagued by gun violence and "relies on this reporting when making the crucial decision whether a license-to-carry applicant should be permitted to carry a firearm," said Mayor Jim Kenney, who is a Democrat like the mayors of New York and San Francisco. "We're joining in this suit because reporting these records is absolutely critical to those decisions. The background check system only works if it contains the proper records."

San Francisco City Attorney Dennis Herrera said in a statement that the Department of Defense's failure to accurately report criminal convictions puts Americans at risk.

"We cannot accept the level of gun violence in our country as 'just the way it is,'" he said.

The lawsuit names the armed forces individually, as well as the Department of Defense, Defense Secretary Jim Mattis and several other officials.

According to the lawsuit, the U.S. Air Force failed to submit records in about 14 percent of cases, the U.S. Navy and Marine Corps failed to submit records in 36 percent of cases, and the U.S. Army didn't submit records in about 41 percent of cases.

The Air Force said it has already made changes designed to prevent such failures in the future. For example, it is now requiring that leaders up the chain of command verify that criminal history reporting requirements have been met in every case. And, additional training on these procedures is being conducted.