The U.S. Supreme Court on Thursday unanimously rejected Philadelphia’s decision to terminate a long-standing contract with a Catholic social services agency over its refusal to consider same-sex married couples as potential foster parents.

But while all nine justices agreed the city’s 2018 move was an unconstitutional violation of Catholic Social Services’ rights to free religious expression, the question of what to do about it split the court.

Church organizations and LGBTQ advocates had watched the case closely, hoping the court would either strike down or renew its endorsement of prior rulings that have allowed laws that may indirectly infringe on religious rights — such as nondiscrimination policies — as long as they are equally applied.

Instead, Chief Justice John G. Roberts Jr., writing for the court, sidestepped the issue by zeroing in on specific language in Philadelphia’s contracts with agencies such as CSS: a clause that allows the city to make exceptions to its nondiscrimination requirements at its discretion.

The city says it has never granted an exemption, but Roberts and the five other justices who joined his opinion concluded that the mere possibility meant the law couldn’t be applied neutrally without making individual judgment calls involving the circumstances of each case.

“The question … is not whether the city has a compelling interest in enforcing its non-discrimination policies generally, but whether it has such an interest in denying an exception to CSS,” Roberts wrote. “CSS seeks only an accommodation that will allow it to continue serving the children of Philadelphia in a manner consistent with its religious beliefs. It does not seek to impose those beliefs on anyone else.”

» READ MORE: What to know about the case

But the court’s narrow ruling sparked confusion among those who had hoped for a bolder stance — either for or against Philadelphia’s nondiscrimination policy and similar measures that have prompted Catholic charities to withdraw from foster contracts and similar policies in cities such as Boston, San Francisco, and Washington, D.C.

Justice Samuel A. Alito Jr. blasted his colleagues in a 77-page concurrence for not tackling the central question of whether such policies could ever be constitutional if they infringe on religious rights.

“This decision might as well be written on dissolving paper sold in magic shops,” he wrote. “If the city wants to get around today’s decision, it can simply eliminate the never-used exemption power. … Then voilà, today’s decision will vanish — and the parties will be back where they started.”

Justices Neil Gorsuch and Clarence Thomas joined Alito in his opinion. And Justice Amy Coney Barrett authored one of her own arguing the court should have gone further and overturned previous precedent.

The ruling’s ambiguity left room for all sides of the issue to declare some semblance of victory — and left unanswered the question of what happens next.

Sharonell Fulton, a foster parent with CSS who as one of the plaintiffs gave the case its name, Fulton v. City of Philadelphia, said she was “overjoyed.”

“My faith is what drives me to care for foster children,” she said. “And I thank God the Supreme Court believes that’s a good thing.”

Archbishop Nelson J. Pérez, who as leader of the Archdiocese of Philadelphia oversees CSS, said he anticipated the agency’s contract would soon be restored.

“It is my personal hope that today’s decision makes it abundantly clear that religious ministries cannot be forced to abandon their beliefs as the price for ministering to those in need,” he said in a statement.

But Mary Catherine Roper of the ACLU, which argued on behalf of two advocacy groups in court, also found reason to celebrate the narrow ruling.

“It does not at all call into question the ability of a municipality like Philadelphia to have a nondiscrimination provision,” she said. “It just says if you’re going to have [one] and enforce it in a way that impacts someone’s religious exercise, it’s going to have to meet a very precise standard.”

City lawyers declined to comment on whether they would — as Alito predicted — simply remove the possibility of exceptions from its policy and continue to refuse to work with CSS.

In a defiant statement, City Solicitor Diana Cortes accused the court of “usurping” the city’s judgment that policies barring LGBTQ discrimination are in the best interest of foster children. She echoed concerns voiced by some legal scholars that the ruling could lead religious groups to seek exemptions in other government contracts.

“Allowing contractors and partners to set their own terms for how they provide public services will create a confusing patchwork … and weaken government non-discrimination guarantees,” she said.

» READ MORE: Sharonell Fulton: My faith led me to foster more than 40 kids; Philly is wrong to cut ties with Catholic foster agencies. | Opinion

As a result of the Thursday’s ruling, the case now returns to the U.S. Court of Appeals for the Third Circuit, the Philadelphia-based panel that decided in the city’s favor in 2019. Should the city continue its dispute with the agency, the case could be almost right back where it started three years ago.

Catholic Social Services had long been one of the leading agencies with which Philadelphia contracted to find, screen, and certify potential caregivers for the almost 5,000 children in the city’s foster system.

But a 2018 Inquirer article highlighted the policy of CSS and another religiously affiliated foster agency that refused to consider same-sex couples. Megan Paszko and her wife were turned away by Bethany Christian Services.

“Deciding to foster, it’s a tough call,” Paszko said Thursday. “I think if you close that gate at all, if you restrict the number of agencies that will even talk to you about becoming a foster parent, all the sudden you made that door a little more closed for that potential parent.”

The city demanded the agencies change their policies. Bethany did. CSS took the city to court.

In the agency’s view, by certifying a couple as good foster candidates it is effectively endorsing their relationship. The city’s demand that CSS consider same-sex couples would force it to sanction marriages that violate a central religious tenet, its lawyers said.

No same-sex couple has ever approached the agency seeking certification. And if one had, its attorneys said, it would have referred them to one of the more than 20 other screening agencies which also hold city foster contracts.

The city defended enforcing nondiscrimination policies, saying they maximize the number of potential foster parents, ensure they and foster children are treated equally, and protect the city from liability.

“As a private citizen, CSS may serve foster families as its faith dictates,” city lawyers wrote in a brief last year. “But when it voluntarily chooses to perform services for the government, it lacks a right to insist upon exercising government authority … in a manner that the city has deemed contrary to the interests of its residents and the children in its care.”

Cynthia Figueroa, Philadelphia’s commissioner of Human Services, which oversees the foster care system, said Thursday that the city is still mulling its next moves, including whether removing the exemption clauses would shield future contracts from legal challenges.

She noted that CSS continues to work with LGBTQ youth and said she worried that allowing it to continue to refuse to work with same-sex foster parents could send a mixed message.

“You’ll be served if you’re a member of the LGBTQ community, but as an adult your rights might not be respected in the same way,” she said. “We greatly value same-sex couples who want to be foster parents. This isn’t going to stop us from recruiting and working with that community.”

Read the opinion: