DALLAS — A subtle design feature of the AR-15 rifle has raised a technical legal question that is derailing cases against people who are charged with illegally buying and selling the gun’s parts or building the weapon.

At issue is whether a key piece of one of America’s most popular firearms meets the definition of a gun that prosecutors have long relied on.

For decades, the federal government has treated a mechanism called the lower receiver as the essential piece of the semiautomatic rifle, which has been used in some of the nation’s deadliest mass shootings. Prosecutors regularly bring charges based on that specific part.

But some defense attorneys have recently argued that the part alone does not meet the definition in the law. Federal law enforcement officials, who have long been concerned about the discrepancy, are increasingly worried that it could hinder some criminal prosecutions and undermine firearms regulations nationwide.

“Now the cat is out of the bag, so I think you’ll see more of this going on,” said Stephen Halbrook, an attorney who has written books on gun law and history. “Basically, the government has gotten away with this for a long time.”

Cases involving lower receivers represent a small fraction of the thousands of federal gun charges filed each year. But the loophole has allowed some people accused of illegally selling or possessing the parts, including convicted felons, to escape prosecution. The issue also complicates efforts to address so-called ghost guns, which are largely untraceable because they are assembled from parts.

Since 2016, at least five defendants have challenged the government and succeeded in getting some charges dropped, avoiding prison or seeing their cases dismissed entirely. Three judges have rejected the government’s interpretation of the law, despite dire warnings from prosecutors.

Federal regulations define a firearm’s “frame” or “receiver” as the piece considered to be the gun itself. But in an AR-15, the receiver is split into upper and lower parts — and some of the components listed in the definition are contained in the upper half. That has led judges to rule that a lower receiver alone cannot be considered a gun.

The lower receiver sits above the pistol grip, holds the trigger and hammer, and has a slot for the magazine. By itself, it cannot fire a bullet. But by treating the piece as a firearm, the Bureau of Alcohol, Tobacco, Firearms and Explosives is able to regulate who can obtain it. Because authorities consider the part to be a gun, people prohibited from having firearms have been charged for possessing them.

In 2018, prosecutors said a ruling against the government would “seriously undermine the ATF’s ability to trace and regulate firearms nationwide.” CNN first reported the case and its implications.

Last month, a federal judge in Ohio dealt the latest blow, dismissing charges against two men accused of making false statements to buy lower receivers.

“Any public citizen would be concerned about this loophole that we exploited,” said attorney Thomas Kurt, who represented defendant Richard Rowold. “As a citizen, I hope the ATF corrects this. As Mr. Rowold’s attorney, I’m grateful the judge followed the law in getting to the correct result.”

The gun industry estimates there are more than 17 million AR-15-style rifles in circulation, and the National Rifle Association once dubbed it “America’s rifle.” AR-15-style weapons were used in attacks in Newtown, Connecticut, Las Vegas and Parkland, Florida.

In the case of Rowold, who is prohibited from buying or possessing firearms because of felony convictions, the government claimed that he used another man as a proxy to purchase 50 lower receivers. The 2018 indictment also charged him with having 15 lower receivers. Kurt declined to comment on why his client had the parts.

The case rested on the ATF’s claim that the components were legally firearms. Judge James Carr called that a “plainly erroneous” reading of the law and said the agency has a duty to fix the problem.

“Misapplying the law for a long time provides no immunity from scrutiny,” Carr wrote in his order to dismiss.

Federal prosecutors in Rowold’s case and several others declined to comment. An ATF spokeswoman would not answer questions posed by The Associated Press but said the agency is “keenly assessing” Carr’s decision.

The problem has attracted attention at the highest levels of law enforcement.

In 2016, then-Attorney General Loretta Lynch wrote a letter to House Speaker Paul Ryan after a judge dismissed a case in Northern California involving a man with a felony record who was accused of buying an unmarked AR-15 lower receiver from an undercover agent.

Prosecutors argued that the case against Alejandro Jimenez should proceed even if the part “does not perfectly fit” the legal definition. The judge dismissed the charges.

The decision prompted Lynch to write that if the ATF wants an AR-15 lower receiver to be considered a firearm under the law, then it should pursue “regulatory or administrative action.” But there’s no public record of the ATF taking such a step.

“I can’t imagine why no one has taken the initiative to correct this,” said Dan O’Kelly, a former senior ATF agent and director of a gun-training company known as International Firearm Specialist Academy. His testimony has guided several defense attorneys.

Since Lynch’s letter, such prosecutions have continued to secure prison sentences.

In April, for instance, an Oklahoma man was charged with illegally possessing a firearm after police who pulled him over found loaded high-capacity magazines and the lower receiver of an AR-15-style rifle in his truck.

Jason Scott Pedro, a 37-year-old with a felony record for domestic violence, was sentenced in November to seven years in prison.

There’s no evidence in court records that Pedro’s lawyer challenged whether the lower receiver was rightly considered a gun. The attorney did not respond to requests for comment but has filed a notice of appeal.

“I think the criminal defense bar has kind of let their clients down for letting this go on for all these years,” Halbrook said.

In one case, an ATF expert testified that the same principle could apply to many other firearms. Prosecutors worry that more rulings against the government could allow people prohibited from having guns to purchase weapons piece by piece with no regulation or background check.

Franklin Zimring, a professor at the University of California, Berkeley School of Law, is skeptical of that claim and said the same behavior could often be prosecuted under state laws.

The AR-15 is a popular model for gun enthusiasts to legally build at home. The rifles are sometimes constructed out of partially machined receivers, often called “80% receivers,” which can be bought and sold without background checks and need not have serial numbers because they are unfinished.

If federal officials want to maintain control in this growing do-it-yourself gun market they need to first establish functional regulation of lower receivers, said Kristen Rand, legislative director at the Washington, D.C.-based Violence Policy Center.

“From a public safety standpoint,” she said, ”this is very important and isn’t just an in-the-weeds legal definitional problem.”

Dazio reported from Los Angeles. Associated Press Writer Lisa Marie Pane in Boise, Idaho, and researcher Jennifer Farrar in New York City contributed to this report.