(Reuters) - A federal judge in Texas on Thursday ruled that guidance issued by President Joe Biden's administration that bars hospitals and other medical providers from using online tracking technologies that monitor users of their websites was unlawful.

U.S. District Judge Mark Pittman in Fort Worth sided with two hospital trade groups including the American Hospital Association and two local healthcare systems in finding that the U.S. Department of Health and Human Services overstepped its authority when it adopted the privacy-promoting guidance policy.

The guidance issued in 2022 warned healthcare providers that allowing third-party technology companies to collect and analyze information collected from visitors of their websites or apps could violate the Health Insurance Portability and Accountability Act (HIPAA).

That 1996 federal law bans the public disclosure of individuals' private health information to protect them against discrimination, stigma or other negative consequences. Hospitals that run afoul of the law can face penalties.

The guidance, issued as a bulletin from the HHS Office of Civil Rights, addressed the hospitals' public-facing websites and said the proliferation of the trackers on healthcare websites can reveal people's diagnoses, frequency of medical visits and put people at risk of other consequences.

But Pittman, an appointee of Republican former President Donald Trump, said HHS went too far by interpreting "individually identifiable health information" protected by HIPAA as also covering metadata from a user's search of a public website.

"To hold otherwise would empower HHS and other executive entities to take increasingly expansive liberties with the finite authority granted to them," Pittman wrote. "The Court is disinclined to set that precedent here."

The judge vacated the guidance, which HHS recently revised after the American Hospital Association, the country's largest hospital lobbying group, and its co-plaintiffs filed their lawsuit in November.

HHS had no immediate comment.

Chad Golder, AHA's general counsel, in a statement said that with the court ruling, "hospitals and health systems will again be able to rely on these important technologies to provide their communities with reliable, accurate health care information."

AHA and its co-plaintiffs filed their case in the federal court in Fort Worth, a venue that has become a favorite of litigants challenging the agenda of Biden, a Democrat, and whose two active judges are Republican appointees.

The guidance was issued as hospitals were increasingly facing class actions accusing them of mishandling patients' information as a result of using analytics technologies provided by Alphabet's Google, Meta Platforms and other third-party companies that gathered data about website visitors.

The agency had argued the guidance was not-binding, and it later revised it to say it does not "have the force and effect of law."

But Pittman said it provided guidance regarding mandatory legal obligations and that such agency guidance can "serve as a Trojan horse for bureaucrats changing the rules of the game."

(Reporting by Nate Raymond in Boston; Editing by Alistair Bell)