A federal judge has thrown out a lawsuit challenging new reporting requirements for gun dealers that the Obama administration says are needed to help staunch the flow of powerful rifles to violent Mexican drug gangs.

Ruling in a suit brought by gun dealers and backed by the National Shooting Sports Foundation as well as the National Rifle ­Association, U.S. District Judge Rosemary M. Collyer of the D.C. district said Friday that the new rules were a reasonable law enforcement tactic.

The suit stemmed from reporting requirements issued in July that required about 8,500 gun dealers in Arizona, California, New Mexico and Texas to alert federal officials to sales of multiple semiautomatic rifles to the same person within five business days. The Bureau of Alcohol, Tobacco, Firearms and Explosives, which mandated the reporting, says that many of the guns used by Mexican drug cartels are purchased from dealers along the border and that obtaining sales data will help authorities more quickly trace seized weapons and investigate associated crimes.

Within weeks of the new rules being made public, gun dealers filed suit to block them. They argued that the requirements ­exceeded ATF’s authority and that Congress never intended there to be a national registration of firearms sales.

Collyer, appointed to the bench by President George W. Bush in 2003, sided with the government, writing that the regulations did not “disturb the balance” between ATF’s efforts to regulate firearms and the privacy rights of gun owners. “ATF determined that certain powerful long guns are weapons of choice for Mexican drug cartels,” Collyer wrote, “and that multiple sales of such guns is a strong indicator of gun trafficking.”

“ATF acted rationally” in asking for sales data in the border states, the judge added.

The NSSF said in a statement Friday that it will appeal the ruling. “Today’s ruling will allow ATF to demand whatever information it wants from any law-abiding retailer anywhere in the country for any reason ATF wants simply by sending a letter demanding information,” the organization said in a statement on its Web site.

“While we understand ATF’s motivation is to try to curtail violence in Mexico, Congress simply has not granted ATF regulatory carte blanche,” the NSSF said.