Three major cities have filed a lawsuit against the Defense Department for its failure to report many criminal convictions in the military justice system to the Federal Bureau of Investigation and its national gun background-check database.

The Pentagon has for years run afoul of federal laws intended to keep guns out of the hands of felons and domestic abusers by not transmitting to the F.B.I. the names of service members convicted of crimes that disqualify gun ownership.

This is what allowed Devin P. Kelley, who was convicted of domestic assault in the Air Force, to buy at a store the rifle he used to kill 25 people, including a pregnant woman whose fetus also died, at a Texas church in November.

Now, after two decades of serious lapses — and one of the worst mass shootings in American history — officials from New York, Philadelphia and San Francisco are trying to force a change. Their suit would require the Pentagon to submit to federal court monitoring of its compliance with the reporting laws it has broken time and again.