WASHINGTON - A sharply divided U.S. Supreme Court ruled Monday that some companies with religious objections can avoid the contraceptives requirement in President Barack Obama's health care overhaul, the first time the high court has declared that businesses can hold religious views under federal law.

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 in what is considered the major success of his first term. Nearly 30 million women receive birth control as a result of the health law, the government has said.

Benefits experts say they expect little impact from the ruling because employers use health benefits to recruit and retain workers. But one constitutional law scholar, Marci Hamilton of Yeshiva University, cautioned that more than 80 percent of U.S. corporations are closely held and she said they could "now be able to discriminate against their employees."

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 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.