WASHINGTON (Reuters) - The U.S. Supreme Court on Monday ruled that church-affiliated hospital systems do not have to comply with a federal law governing employee pensions, overturning lower court decisions that could have cost the hospitals billions of dollars.

FILE PHOTO: The Supreme Court is seen ahead of the Senate voting to confirm Judge Neil Gorsuch as an Associate Justice in Washington, DC, U.S. on April 7, 2017. REUTERS/Aaron P. Bernstein/File Photo

The court ruled 8-0 that church-affiliated organizations are exempt from the Employee Retirement Income Security Act, a 1974 law that forces private employers to follow rules aimed at protecting pension plan participants.

The ruling was a victory for New Jersey-based Saint Peter’s Healthcare System, Illinois-based Advocate Health Care Network and California-based Dignity Health, which had faced separate employee lawsuits accusing them of wrongly claiming a religious exemption under ERISA.

Federal agencies had long interpreted the law as exempting not just church plans but also those of church-affiliated organizations.

The employees challenged that view, in effect accusing the hospital systems of being big businesses posing as church organizations in order to avoid minimum funding and reporting requirements under ERISA.

The three hospital systems maintained that their religious affiliation made them exempt from ERISA. St. Peters is affiliated with the Roman Catholic Church. Dignity operates both Catholic and non-Catholic hospitals. Advocate is affiliated with the United Church of Christ and the Evangelical Lutheran Church in America.

Writing for the court, Justice Elena Kagan said the law’s religious exemption applies to plans whether they were established by churches themselves or organizations affiliated with the churches.

Justice Sonia Sotomayor agreed with the ruling based on the text of the law. But, in a separate opinion, she wrote that she was “troubled” with the outcome, noting that some church-affiliated organizations operate for-profit subsidiaries, earn billions of dollars in revenues and compete with companies that must comply with ERISA.

Sotomayor suggested that the U.S. Congress take action, adding that “scores of employees - who work for organizations that look and operate much like secular businesses - potentially might be denied ERISA’s protections.”

The ruling is the latest in which the justices endorsed the idea that certain businesses deserve wider latitude because of religious considerations. In 2014, the justices sided with Hobby Lobby, a retailer owned by conservative Christians, that objected to a federal requirement that it pay for insurance coverage for women’s birth control, saying that violated a U.S. law protecting religious freedom.

Three separate regional federal appeals courts had ruled against Saint Peter’s, Advocate and Dignity in separate cases, refusing to dismiss employees’ lawsuits against them.

Hundreds of hospitals and hospital systems have claimed the exemption since 1980, when Congress amended ERISA to extend what is known as the “church plan” exemption, originally only for churches, more broadly to certain religiously affiliated entities.

The plaintiffs were seeking retroactive penalties for past violations of ERISA, which the hospitals said could add up to hundreds of millions or billions of dollars.

Justice Neil Gorsuch, who joined the court after the arguments were presented in the case, did not participate in Monday’s decision.