A San Diego County Superior Court judge Tuesday granted an injunction preventing a nonprofit group from operating a needle-exchange program in Orange County.

Orange County officials in August filed a lawsuit challenging the program, which was being run by the nonprofit and was authorized by the California Department of Public Health, Office of AIDS.

The Orange County Needle Exchange Program operated the program from 2016 through January of this year in Santa Ana when the Civic Center area was home to a large encampment of transients. But the group hoped to expand the program to Anaheim, Costa Mesa and Orange.

Orange County officials objected, saying there was a proliferation of discarded syringes in the Santa Ana area when the program was operating, and they feared a larger problem if the program expanded to other cities.

"The public safety of our residents comes first," Orange County Board of Supervisors Chairman Andrew Do said. "We fought to make sure our sidewalks, parks and libraries did not become hazardous waste sites."

Judge Joel Wohlfeil ruled Tuesday that the Orange County Needle Exchange Program lacked enough workers to staff the program and pick up and dispose of used syringes.

The judge praised the "selfless devotion" of the nonprofit's volunteers, but concluded there wasn't enough staff to run the program.

County officials had argued the program was a "public nuisance" because it lacked resources to dispose of discarded needles. In his ruling, Wohlfeil wrote that the nonprofit's "area sweeps" for discarded syringes did "little to mitigate the syringe litter complained of by" the county.

"The seriousness of the harm outweighs the social utility of defendant's conduct," Wohlfeil wrote. "Defendants have presented substantial evidence to support the social utility of (the program). ... However, the program's public health objective is no more important than the public safety objective advocated by plaintiffs."

Mahan Naeim, who was on the steering committee of the Needle Exchange Program, criticized the ruling and said the nonprofit was discussing its legal options.

"It's a very disappointing ruling," he said, adding he was speaking for himself and not the nonprofit officially. "Needle exchange programs are not a radical idea. They exist in cities throughout the country."

Naeim said he felt Wohlfeil's ruling "placed social stigma above data and evidence."

Do criticized the program for handing out 20 needles for every one an addict turned in. He argued that about 14,000 needles were recovered on a four-mile stretch along the Santa Ana riverbed when an encampment there was cleared out.

But Naeim has explained that while someone might receive 20 syringes for turning one in, "If you bring in 100, you get 120 needles. If you bring in 200, you get 200 and if you bring in 500 you get 200."

The program would cap out a daily distribution at 200.

On Dec. 16 of last year, the program had 240 clients who turned in 30,122 needles and the nonprofit doled out 30,333 needles, Naeim said.

The program was designed to "incentivize" participants to bring in needles so that they can be disposed of properly, he said.