The firearms industry trade group, the National Shooting Sports Foundation, and two Arizona gun sellers had argued that the administration overstepped its legal authority in the 2011 regulation, which applies to gun sellers in California, Arizona, New Mexico and Texas.

The requirement, issued in what is known as a demand letter, compels those sellers to report to the Bureau of Alcohol, Tobacco, Firearms and Explosives when anyone buys — within a five-day period — two or more semi-automatic weapons capable of accepting a detachable magazine and with a caliber greater than .22. The ATF says the requirement is needed to help stop the flow of guns to Mexican drug cartels.

Judge Karen LeCraft Henderson, writing for the three-judge panel of the U.S. Court of Appeals for the District of Columbia Circuit, said the agency was within its legal authority when it issued the demand letter. She said that the Gun Control Act of 1968 "unambiguously authorizes the demand letter."

Henderson, who was appointed by Republican President George H.W. Bush, was joined by Judges Judith W. Rogers, an appointee of Democratic President Bill Clinton, and Harry T. Edwards, an appointee of Democratic President Jimmy Carter.

Congress annually passes legislation banning the ATF from establishing a national firearms registry, but Henderson rejected arguments from the challengers that the requirement unlawfully created one.

Because ATF sent the demand letter to only 7 percent of federally licensed gun dealers and required information about only a small number of transactions, "the July 2011 demand letter does not come close to creating a 'national firearms registry,'" she wrote.

The National Shooting Sports Foundation had argued that even if the ATF had the legal authority to issue the requirement, its decision to impose it on every retailer in the border states was arbitrary and capricious. In its appeal brief, the group wrote, "There is no rational law enforcement connection between the problem ATF sought to address — illegal firearms trafficking from the United States to Mexico — and merely conducting a lawful retail firearms business from premises located in one of the border states."

But the panel dismissed this challenge as well. Henderson wrote that an agency has "wide discretion" in making line-drawing decisions, and that the problem ATF sought to address is most severe in Arizona, California, New Mexico and Texas.

Larry Keane, general counsel of the National Shooting Sports Foundation, said in a telephone interview Friday that his group has always encouraged gun sellers to fully cooperate with law enforcement and report any suspicious activity.

"We simply do not believe that Congress gave the ATF carte blanche authority to demand records from licensees for any reason it wants for as long as it wants," he said.

Keane added that there are two other appeals pending on the ATF requirement in other judicial circuits.

Richard Gardiner, an attorney for the two Arizona gun dealers that had challenged the requirement, J&G Sales, Ltd., of Prescott, Ariz., and Foothills Firearms, LLC, of Yuma, Ariz., said he was disappointed with the ruling but hasn't decided yet whether to file an appeal or not.