WASHINGTON, D.C.  — The Supreme Court seemed to struggle on Monday over whether some of the nation’s largest hospitals should be allowed to sidestep federal laws protecting pension benefits for workers.

Justices considered the cases of three church-affiliated nonprofit hospital systems being sued for underfunding pension plans covering about 100,000 employees. But the outcome ultimately could affect the retirement benefits of roughly a million employees around the country.

The hospitals — Advocate Health Care Network, Dignity Health, and Saint Peter’s Healthcare System — say their pensions are “church plans” exempt from the law and have been treated as such for decades by the government agencies in charge. They want to overturn three lower court rulings against them.

Workers suing the health systems argue that Congress never meant to exempt them and say the hospitals are shirking legal safeguards that could jeopardize retirement benefits.

“I’m torn,” Justices Sonia Sotomayor said at one point during the hour-long argument. “This could be read either way in my mind.”

Justice Anthony Kennedy said the Internal Revenue Service issued hundreds of letters over more than 30 years approving the hospitals’ actions. That shows they were “proceeding in good faith with the assurance of the IRS that what they were doing was lawful,” he said.

The case could affect dozens of similar lawsuits over pension plans filed across the country.

Much of the argument focused on how to read a federal law that generally requires pension plans to be fully funded and insured. Congress amended that law in 1980 to carve out a narrow exemption for churches and other religious organizations.

But in each of the three cases, appeals courts in San Francisco, Chicago and Philadelphia ruled that the exemption applies only to plans that were established by a church.

The Becket Fund for Religious Liberty filed an amicus brief arguing this interpretation is too narrow, since the Supreme Court has long recognized churches are not limited to how they pray or worship, “but includes teaching and serving others as well.”

The brief argued that to rule against the religious hospitals would punish them for not engaging in “the government’s favored category of religious exercise.”

Hospital lawyer Lisa Blatt told the justices that Congress wanted to exempt plans associated with or controlled by a church, whether or not a church itself created the plan. She said federal agencies including the IRS and the Labor Department have assured them for decades that they are exempt.

Blatt said a ruling against the hospitals would “jettison 30 years of settled expectations” and open the hospitals to billions in liability.

Catholic organizations run more than 600 hospitals and 1,400 long-term care and other health facilities in all 50 states.

Justice Elena Kagan said if Congress wanted a broader exemption, it used “very odd language” instead of being more straightforward.

Arguing for the workers, lawyer James Feldman said Congress was very zealous about creating exceptions to pension laws and did not intend to exempt these hospitals. He said the IRS letters wrongly interpreted the law and can’t be relied on.

“These plans have zero involvement with any church,” Feldman said.

Justice Samuel Alito seemed to side with the hospitals, noting that these and other similar lawsuits exposed the hospitals to billions in damages.

The federal government is backing the hospitals. Justice Department lawyer Malcolm Stewart acknowledged that Congress could have made the law clearer, but he said lawmakers wanted to protect hospitals like those being sued.

California-based Dignity Health formed in 1986 from the merger of two Catholic hospital systems. Illinois-based Advocate Health Care Network is affiliated with the Evangelical Lutheran Church in America and the United Church of Christ. Saint Peter’s is owned by the Roman Catholic Diocese of Metuchen, New Jersey, and is headquartered in New Brunswick.

The U.S. Conference of Catholic Bishops joined with the Association of Catholic Colleges and Universities, Catholic Charities USA, Catholic Relief Services, and the National Catholic Educational Association in filing an amicus brief on the case arguing that determining “whether a ministry is part of the church is a question for the church,” not the federal government.

“Asking courts to make those kinds of probing and individualized determinations would foster exactly the kind of ‘excessive entanglement between government and religion’ that the religion clauses of the First Amendment are intended to avoid,” the brief said.

A ruling is expected by late June.

Crux staff contributed to this report.