Birth control pills are shown. A U.S. appeals court on Thursday partially blocked rules by the Trump administration allowing more employers to opt out of providing women with no-cost birth control. (Rich Pedroncelli/AP)

A divided panel of a federal appeals court in California on Thursday partially upheld a decision blocking a set of rules from the Trump administration that allowed some employers to deny insurance coverage of birth control because of religious or moral reasons.

The rules, issued by the Department of Health and Human Services in October 2017, vastly expanded the range of companies that could opt out of an Affordable Care Act mandate that required employers to cover contraception at no cost for the employee.

In December 2017, California and three other states filed a lawsuit over the rules, and a lower court issued a nationwide preliminary injunction blocking the rules from taking effect. Thursday’s decision, from the U.S. Court of Appeals for the 9th Circuit, upheld that decision — but only in the five states that sued, California, Delaware, Maryland, New York and Virginia.

In a 2-1 decision, the panel of judges held that the Department of Health and Human Services enacted its rules without the notice and comment period required by federal law. But the judges concluded that the scope of the preliminary injunction was overly broad “and that the district court abused its discretion in that regard,” Judge J. Clifford Wallace wrote.

The panel ruled that it was “reasonably probable” that the five states would suffer irreparable economic harm by the rules but that the facts in the case did not sufficiently demonstrate a nationwide detrimental impact.

While Thursday’s decision would allow enforcement of the rules in many states, a preliminary injunction in a separate case in Pennsylvania remains in effect, meaning the rules are still blocked nationwide.

Complicating matters further, the Trump administration last month issued a new set of federal rules similar in language to the 2017 rules, allowing some companies to opt out of birth control coverage on religious or nonreligious “moral convictions.” When the new Trump administration rules take effect Jan. 14, they will supersede the 2017 rules, and the injunctions in California and Pennsylvania will be moot.

The new rules do not allow publicly traded companies or governments to claim such exemptions, and the number of companies that would opt for such exemptions is unclear. The Trump administration has predicted that the impact of the rules would be limited, affecting the coverage of birth control for an estimated 6,400 women. But several states and advocacy groups have argued the impact would be much larger, severely restricting access to contraception.

California Attorney General Xavier Becerra has argued that potentially millions of women in California could be left without access to birth control and counseling and that the state would have to shoulder the additional financial and administrative burden.

The birth control rules are part of a broader effort by the Trump administration to side with conservatives who have sought to prioritize what they consider “religious liberty” concerns, and who vehemently opposed the Obama-era birth control mandate.

The American College of Obstetricians and Gynecologists has supported the mandated coverage, saying access to birth control is “a medical necessity” for women.