In a ruling that may create momentum behind the idea in Massachusetts, a federal judge ruled Wednesday that supervised consumption sites, where individuals could use pre-acquired drugs under medical watch without facing arrest, would not violate a section of the Controlled Substances Act as government prosecutors alleged.

The U.S. government filed a civil lawsuit against Safehouse, a nonprofit in Pennsylvania, over its plans to open the country's first supervised consumption site in Philadelphia. Federal attorneys argued that a CSA provision sometimes referred to as the "crack house statute" bars the organization from opening a facility where drugs would be used openly.

Pennsylvania Eastern District Court Judge Gerald McHugh ruled Wednesday that Safehouse's proposal would not run afoul of that section of the law because its ultimate goal is to reduce drug use by keeping individuals with substance use disorders alive and pushing them toward treatment.

"Safehouse plans to make a place available for the purposes of reducing the harm of drug use, administering medical care, encouraging drug treatment, and connecting participants with social services," McHugh wrote in his decision. "None of these purposes can be understood as a purpose to facilitate drug use."

The case is being closely watched in Massachusetts, where lawmakers have pressed to launch a supervised consumption pilot program as a way to mitigate the opioid epidemic's death toll and where U.S. Attorney Andrew Lelling has threatened to prosecute any such effort.

State lawmakers have struggled to reach conclusions about authorizing safe drug consumption sites in Massachusetts, grappling with opposition to the idea, questions about its legality, implications for professional caregivers at the sites, and the potential for sites to slow the trend of opioid overdoses.

Somerville Mayor Joe Curtatone has indicated that he plans to open a site in his city in 2020, regardless of legal questions.

Sen. Cindy Friedman, who served on a commission that this spring recommended the state pilot one or more sites, said the ruling "gives us momentum in Massachusetts to move our harm-reduction site pilot forward."

"It is distressing that U.S. Attorney Lelling would try to create a barrier to desperately needed harm-reduction care for those suffering from a terrible illness," Friedman said in a statement. "Conflating harm reduction sites with crack houses is ridiculous and dangerous. Establishing pilot sites is a logical, thoughtful, and humane action we must continue to push for in Massachusetts to reduce harm and save lives."

Michael P. Norton contributed reporting.