The Supreme Court today backed craft retailer Hobby Lobby’s challenge to the Affordable Care Act, ruling in a 5-4 opinion that closely held for-profit companies can’t be required to provide health coverage for contraceptives over the owners’ religious objections.

The decision involved the Religious Freedom Restoration Act of 1993 which prevents the government from burdening a person’s exercise of religion unless there is a compelling government interest and it is done in the least restrictive manner.  The court said the government failed to show that Affordable Care Act’s contraceptive mandate is the least restrictive means of advancing access to birth control.

Protecting closely-held corporations’ rights of religious exercise “protects the religious liberty of the humans who own and control them,” the court ruled. The ruling is “very specific,” and doesn’t mean that any corporation can opt out of any law that it deems incompatible with the owners’ religious beliefs, the majority opinion said, addressing concerns of dissenting justices.

This ruling dealt just with contraception and not all insurance mandates (say, for blood transfusion or vaccinations). The court made clear that it did not provide the leeway for employers to use religious practice to disguise illegal discrimination, such as that based on race.

Related: Obamacare: What Will it Cost if You Don't Comply?

The ACA, or Obamacare, effectively requires companies with more than 50 full-time employees to provide health insurance that includes a package of specific benefits, including certain forms of birth control. Obamacare allows non-profit religious organizations an exemption from covering employees’ contraceptives.

Hobby Lobby, a family-owned national chain, and another family-owned for-profit company, Conestoga Wood Specialties, contended that the RFRA allows their businesses to withhold coverage for contraceptives that infringe on the owners’ Christian beliefs. Hobby Lobby’s owners, the Green family, oppose four of the 20 Food and Drug Administration-approved forms of contraception on religious grounds, considering them to be similar to abortion.

Related: Who Can Claim Exceptions Under Obamacare? Supreme Court to Weigh In.

The RFRA protects a person’s rights to exercise religion, and, argued Hobby Lobby, a “person” should be defined to include both individual people and corporations. The Obama administration had contended that the Greens’ religious beliefs do not justify allowing Hobby Lobby an exemption from complying with the ACA, which regulates companies and not their individual owners.

The court, in a majority opinion by Justice Samuel Alito, said the administration’s position “would leave merchants with a difficult choice: give up the right to seek judicial protection of their religious liberty or forgo the benefits of operating as corporations.” 

“Any suggestion that for-profit corporations are incapable of exercising religious because their purpose is simply to make money flies in the face of modern corporate law,” the court said.

The Department of Health and Human Services already has made accommodation for religious nonprofit employers that opt out of covering contraceptives and could extend that accommodation, the court said. In such as case, Hobby Lobby’s female employees could continue to receive coverage for FDA-approved contraceptives, at no cost, because the employer’s insurers would be responsible for providing information and coverage, the opinion stated.

The court also said the government could assume the costs of providing the four contraceptives to women whose employers won’t cover them because of religious objections.

Dissenting Justice Ruth Bader Ginsburg called the decision one of "startling breadth," that ruled that commercial enterprises "can opt out of any law -- saving only tax laws -- they judge incompatible with their religious beliefs." 

The court, she said, views the RFRA as demanding accommodation for a for-profit company's religious beliefs "no matter the impact that accommodation may have on third parties who do not share the corporation owners' religious faith -- in these cases, thousands of women employed by Hobby Lobby and Conestoga or dependents of persons those corporations employ." Congress enacted RFRA "to serve a far less radical purpose," Ginsburg said, adding that the court's ruling could introduce "havoc."

While the court said that a less restrictive alternative is at hand -- extending the accommodation provided to religious nonprofits -- Ginsburg noted that the majority declined to rule on the lawfulness of that accommodation.

In addition to coverage guidance, the decision can help Hobby Lobby sidestep crushing fines. Under the ACA, companies with more than 50 full-timers that don’t offer any health care, pay a $2,000 fine per staffer each year (for all but 30 people). Companies with more than 100 full-timers would pay that fine in 2015. Had it taken that route, Hobby Lobby (with 13,000 employees) estimated that its fines could have totaled $26 million a year.

A separate fine dictates that health plans must cover contraceptives. Companies that don't comply can be required to pay $100 per day, per person eligible. For Hobby Lobby, that could have amounted to more than $475 million a year.