Lauren Ehrsam, a Justice Department spokeswoman, said: “We disagree with the court’s ruling and are evaluating next steps. This administration is committed to defending the religious liberty of all Americans, and we look forward to doing so in court.”

But Mr. Shapiro said that the court ruling on Friday was a victory for millions of women.

“Donald Trump broke the law to undermine women’s health, and women here in Pennsylvania stood up and proved that in court,” Mr. Shapiro said. “Together we’ve won a nationwide halt to these rules.”

The court order is a first step in what could be lengthy litigation. It “maintains the status quo pending the outcome of a trial on the merits” of the state’s claims, Judge Beetlestone said. Similar claims have been made in lawsuits filed by women’s rights groups; female students and employees; and several other states, including California, Massachusetts and New York.

President Barack Obama signed the Affordable Care Act in March 2010. One section of the law requires coverage of preventive health services and screenings for women. In August 2011, the Obama administration required employers and insurers to provide women with coverage at no cost for all methods of contraception approved by the Food and Drug Administration.

Judge Beetlestone said Pennsylvania had standing to sue the Trump administration because women denied coverage under the new rules were likely to “seek state-funded sources of contraceptive care,” generating additional costs for the state.

Federal officials estimated that at least 31,700 women could lose contraceptive coverage under the new rules, the judge said, and “there are reasons to believe the number is significantly higher.”

Moreover, Judge Beetlestone said, the state has an interest in protecting the health of its citizens.