The justices' 5-4 decision, splitting conservatives and liberals, means the Obama administration must search for a different way of providing free contraception to women who are covered under the health insurance plans of objecting companies.
Justice Samuel Alito wrote in his majority opinion, over a dissent from the four liberal justices, that forcing companies to pay for methods of women's contraception to which they object violates the 1993 Religious Freedom Restoration Act. He said the ruling is limited and there are ways for the administration to ensure women get the birth control they want.
But White House press secretary Josh Earnest said the decision creates health risks for women, and he said Congress should take action to make sure they get coverage.
"President Obama believes that women should make personal health care decisions for themselves rather than their bosses deciding for them," Earnest said. "Today's decision jeopardizes the health of the women who are employed by these companies."
Contraception is among a range of preventive services that must be provided at no extra charge under the health care law that Obama signed in 2010.
Two years ago, Chief Justice John Roberts cast the pivotal Supreme Court vote that saved the law in the midst of Obama's campaign for re-election. On Monday, Roberts sided with the four justices who would have struck down the law in its entirety, holding in favor of the religious rights of closely held corporations, like the Oklahoma-based Hobby Lobby chain of arts-and-craft stores that challenged the contraceptives provision.
Hobby Lobby is among roughly 50 businesses that have sued over covering contraceptives. Some, like the two involved in the Supreme Court case, are willing to cover most methods of contraception, as long as they can exclude drugs or devices that the government says may work after an egg has been fertilized.
But Monday's ruling would apply more broadly to other companies that do not want to pay for any of the 20 birth control methods and devices that have been approved by federal regulators.
Alito said the decision is limited to contraceptives. "Our decision should not be understood to hold that an insurance-coverage mandate must necessarily fall if it conflicts with an employer's religious beliefs," he said.
He suggested two ways the administration could deal with the birth control issue. The government could simply pay for pregnancy prevention, he said. Or it could provide the same kind of accommodation it has made available to religious-oriented, not-for-profit corporations.
Those groups can tell the government that providing the coverage violates their religious beliefs. At that point, creating a buffer, their insurer or a third-party administrator takes on the responsibility of paying for the birth control. The employer does not have to arrange the coverage or pay for it. Insurers get reimbursed by the government through credits against fees owed under other provisions of the health care law.
That accommodation is the subject of separate legal challenges, and the court said Monday that profit-seeking companies could not assert religious claims in such a situation.
Justice Anthony Kennedy, who was part of the majority, also wrote separately to say the administration can solve its problem easily. "The accommodation works by requiring insurance companies to cover, without cost sharing, contraception coverage for female employees who wish it," Kennedy said. He said that arrangement "does not impinge on the plaintiffs' religious beliefs."
Houses of worship and other religious institutions whose primary purpose is to spread the faith are exempt from the requirement to offer birth control.
In a dissent she read aloud from the bench, Justice Ruth Bader Ginsburg called the decision "potentially sweeping" because it minimizes the government's interest in uniform compliance with laws affecting the workplace. "And it discounts the disadvantages religion-based opt-outs impose on others, in particular, employees who do not share their employer's religious beliefs," Ginsburg said.
Leaders of women's rights groups blasted the decision by "five male justices," in the words of Cecile Richards, president of the Planned Parenthood Action Fund.
The administration said a victory for the companies would prevent women who work for them from making decisions about birth control based on what's best for their health, not whether they can afford it. The government's supporters pointed to research showing that nearly one-third of women would change their contraceptive if cost were not an issue; a very effective means of birth control, the intrauterine device, can cost up to $1,000.
The contraceptives at issue before the court were the emergency contraceptives Plan B and ella, and two IUDs.
A survey by the Kaiser Family Foundation found 85 percent of large American employers already had offered such coverage before the health care law required it.
Most working women will probably see no impact from the ruling, corporate health benefits consultants expect. Publicly traded companies are unlikely to inject religion into their employee benefit plans, said Mark Holloway, director of compliance services at the Lockton Companies, an insurance broker that serves medium-sized and growing employers.
"Most employers view health insurance as a tool to attract and retain employees," said Holloway. "Women employees want access to contraceptive coverage, and most employers don't have a problem providing that coverage. It is typically not a high-cost item."
It is unclear how many women potentially are affected by the high court ruling. Hobby Lobby is by far the largest employer of any company that has gone to court to fight the birth control provision.
The company has more than 15,000 full-time employees in more than 600 crafts stores in 41 states. Hobby Lobby is owned by the family of David Green, evangelical Christians who also own Mardel, a Christian bookstore chain.
The other company is Conestoga Wood Specialties Corp. of East Earl, Pennsylvania, owned by a Mennonite family and employing 950 people in making wood cabinets.
Associated Press writers Ricardo Alonso-Zaldivar, Jessica Gresko and Jim Kuhnhenn contributed to this report.