WASHINGTON (AP) — A federal judge Monday blocked a major White House initiative on prescription drug costs, saying the Trump administration lacked the legal authority to require drugmakers to disclose their prices in TV ads.

The narrow ruling by U.S. District Judge Amit Mehta in Washington, D.C., struck down a requirement that was set to go into effect within hours, on Tuesday. Drugmakers had argued that requiring them to disclose list prices amounted to coercion that would violate their free speech rights under the Constitution.

But in his 27-page ruling Mehta avoided debating the First Amendment, saying simply that the Trump administration had failed to show it had legal authority under the statutes that govern federal programs such as Medicare to require price disclosure.

He wrote that neither the law’s “text, structure, nor context evince an intent by Congress to empower (administrative agencies) to issue a rule that compels drug manufacturers to disclose list prices.”

Mehta also said he wasn’t questioning the motives of the Health and Human Services Department, which issued the price disclosure rule. He suggested the administration could even be right on the merits.

“That policy very well could be an effective tool in halting the rising cost of prescription drugs,” the judge wrote. “But no matter how vexing the problem of spiraling drug costs may be, HHS cannot do more than what Congress has authorized. The responsibility rests with Congress to act in the first instance.”

READ MORE: Why drug prices listed in TV ads might not be what you pay

HHS spokeswoman Caitlin Oakley said the administration was disappointed by the ruling and “will be working with the Department of Justice on next steps related to the litigation.” The administration could appeal the ruling, and it could also ask Congress to specifically authorize requiring drugmakers to disclose their prices. The Senate and the House are working on a package of bills that aim to reduce health care costs for insured patients, and drug prices are one of lawmakers’ biggest targets.

The lawsuit was brought by three major manufacturers, Merck, Eli Lilly and Amgen. HHS Secretary Alex Azar was once a top executive of Indianapolis-based Eli Lilly.

AARP vice president Nancy LeaMond also called the ruling a disappointment. “Today’s ruling is a step backward in the battle against skyrocketing drug prices,” she said in a statement. “Americans should be trusted to evaluate drug price information and discuss any concerns with their health care providers.”

Mehta was nominated to the federal bench by former President Barack Obama.

WATCH: Trump advocates push against ‘surprise medical bills’