A federal judge on Wednesday voided the Trump administration’s “conscience rule,” which would have made it easier for health care workers to avoid assisting with abortion or other medical procedures on religious or moral grounds.

Hospitals, insurance companies or local governments that violated their employees’ rights under the rule could have faced a loss of federal funds.

The rule is part of a broader agenda by the Trump administration, which says it wants to expand protections for the civil rights of health care workers, even as critics say it has weakened civil rights protections for certain patients. President Trump announced the rule last May at a Rose Garden event for the National Day of Prayer.

The rule had been scheduled to go into effect later this month.

The judge, in a 147-page opinion, said that the Department of Health and Human Services did not have the authority to impose major portions of the rule and that the agency’s “stated justification for undertaking rule making in the first place — a purported ‘significant increase’ in civilian complaints relating to the conscience provisions — was factually untrue.”

“Where H.H.S. claimed that the rule was justified by complaints made to it, the administrative record reflects a yawning evidentiary gap,Judge Paul A. Engelmayer of United States District Court wrote.

It was unclear on Wednesday whether the Trump administration would appeal the ruling. The Department of Health and Human Services said in a statement that it and the Justice Department were reviewing the opinion and that it had no comment at this time.

The decision drew praise from New York State’s attorney general, Letitia James, and the City of New York, each plaintiffs in the suit. “Health care is a basic right that should never be subject to political games,” Ms. James said in a statement.

But Daniel Blomberg, a senior counsel at Becket, a religious liberty legal advocacy group, expressed disappointment. Becket represented the Christian Medical and Dental Associations, a defendant in the case alongside the government.

“Today’s decision in New York v. H.H.S. harms doctors and patients nationwide by forcing medical professionals to choose between their faith and their life’s calling,” Mr. Blomberg said in a statement.

Mr. Blomberg said his clients were reviewing the ruling before deciding whether to appeal.

Opponents of the rule called the policy proposal discriminatory. Alexis McGill Johnson, the acting president of Planned Parenthood, which was also a plaintiff, said the Trump administration, because of the ruling, “was blocked from providing legal cover for discrimination.”

This rule put patients’ needs last and threatened their ability to access potentially lifesaving health care,” she added.

The case was brought by 19 states, three cities, a county and two reproductive health providers that said they were concerned the rule would prevent vulnerable patients from obtaining needed care. The case was one of several lawsuits filed around the country objecting to the policy.

The rule built on existing civil rights protections for religious health care workers by pulling together more than 25 separate laws — including some pertaining to abortion and end-of-life care — into one framework. The rule would have allowed medical providers to refuse care if it conflicted with their religious or moral convictions, and would have allowed them to decline to refer patients to another provider with no such objections.

Hospitals, health plans and local governments that compelled their workers to perform such tasks despite objections would have been subject to penalties, including a potential loss of all federal funding.

Those subject to the rule’s protections, the judge noted, would have included not just clinical workers, but also people like ambulance drivers, schedulers — even elevator operators.

In a recent oral argument, Judge Engelmayer pressed a Justice Department lawyer on a hypothetical: What would happen if an ambulance driver with objections to abortion were transporting a pregnant woman across Central Park to Mount Sinai Hospital in Manhattan, only to learn during the ride that she was headed there to terminate an ectopic pregnancy.

“The driver tells her to get out in the middle of the park?” the judge said.

The government’s lawyer acknowledged that an employer that forced the driver to continue would violate the rule.

Judge Engelmayer, who was appointed by President Barack Obama in 2011, wrote that the rule authorized the government to withhold or terminate funding if a state or other recipient “failed, even once, to comply with a conscience provision.” The judge said such a stiff penalty was “impermissibly coercive,” given the scale of the funding it potentially jeopardized.

Though many of the underlying provisions have existed for decades, the Trump administration’s conscience rule was a new regulation meant to interpret their meaning and clarify enforcement procedures.

In its rollout of the policy, administration officials said the number of conscience complaints from health care workers had increased sharply. They told the court that complaints rose from about one a year during the Obama presidency to 358 between November 2016 and the end of the 2018 fiscal year.

But the judge said officials had mischaracterized many of those complaints. Of the 358, for example, 22 were exact duplicates, the judge wrote. And of the remaining 336 “unique complaints,” nearly 80 percent were related to vaccinations, which the rule does not cover. An additional 49 complaints, the judge said, were unrelated to the rule for other reasons.

Judge Engelmayer then quoted from an exchange he had with a government lawyer at oral argument held last month.

“Are we down to about 20?” the judge said.

“Yes,” the lawyer acknowledged. “In that ballpark.”

Judge Engelmayer said that the government’s claim of a significant increase in such complaints was “demonstrably false.”

The rule vacated by the court originated in the Office for Civil Rights within the Health and Human Services Department, an office that has been expanded under President Trump to add a conscience and religious freedom division.

Roger Severino, its director, has made expanding protections for religious health care workers a priority. Mr. Trump, who sees conservative Christians as an essential part of his support during his re-election effort, has sought to expand the office’s funding.