A group of mostly Democratic states filed lawsuits against the Trump administration on Tuesday, challenging a new federal rule that gives health-care providers, insurers and employers greater latitude to refuse to provide or pay for medical services that they say violate their religious or moral beliefs.

A lawsuit by a coalition of nearly two dozen states and cities, led by New York Attorney General Letitia James, alleges that the rule illegally favors the personal views of health-care workers over the needs of patients — “at a dangerous price” of hobbling the ability of state-run health-care facilities to provide effective care.

A separate suit, brought by California Attorney General Xavier Becerra, alleges that the rule “impedes access to basic care” and “encourages discrimination against vulnerable patients,” including women and LGBTQ individuals.

The suits, plus one brought earlier this month by the city of San Francisco, seek to block the rule, announced by President Trump early this month and published Tuesday in the Federal Register. It allows individuals and entities to refrain from delivering or paying for services such as abortion, sterilization or assisted suicide if they have a religious or moral objection to them. The 440-page rule also grants parents rights to refuse several specific types of care for their children.

The lawsuits are part of a spate of federal litigation challenging various ways the Trump administration has been rewriting health-care policies. So far, courts have issued temporary injunctions to block some of the policies while the disputes play out in court.

Injunctions by two courts last month halted new antiabortion restrictions on the use of money for family planning services under the Title X program. A federal judge in the District, meanwhile, has ruled against the administration’s approval of steps taken by Kentucky and Arkansas to require some poor residents on Medicaid to work or prepare for jobs to qualify for the benefits.

The “conscience protections,” as their advocates call them, are among actions taken by the Department of Health and Human Services that appeal to Christian conservatives, a constituency that is part of Trump’s political base. The rule is due to take effect in late July.

The multistate lawsuit, filed in the U.S. District Court for the Southern District of New York, alleges that the rule puts at risk billions of dollars in federal funds if the states participating in the case do not comply.

The 80-page complaint says the rule also will harm teaching hospitals and other health-care facilities run by some of the states and cities, undermining their effectiveness and forcing them to hire extra staff in case some workers refuse care that patients need. The rule also risks “undermining longstanding efforts by those institutions to build trust with the patient communities they serve,” the suit says.

The suit further alleges that the rule violates several federal laws, including those governing Medicare and Medicaid, civil rights statutes, and a statute requiring hospitals to provide emergency care.

In addition to New York, the plaintiffs are Colorado, Connecticut, Delaware, Hawaii, Illinois, Maryland, Massachusetts, Michigan, Minnesota, Nevada, New Jersey, New Mexico, Oregon, Pennsylvania, Rhode Island, Vermont, Virginia and Wisconsin, plus the cities of Chicago and New York; Cook County, Ill.; and the District.