As the world waited for the Supreme Court's ruling in Fulton v. City of Philadelphia, the battle lines were drawn for another epic battle in our never-ending culture wars. The religious liberty of a Catholic foster care agency was set against a municipal government committed to ending discrimination against same-sex couples.

Then, last week, as advocates on both sides readied their outrage-armed fundraising machines, the court issued its ruling in favor of the Catholic agency. And remarkably, it was unanimous — demonstrating once again that the rule of law does not stick to our polarized political scripts.

Throughout this era of tumult and tribalism, our judiciary has reminded us that the law is not just a set of political preferences dressed up in fancy words. Principles and precedent matter.

The dispute arose from Philadelphia's decision not to renew its contract with Catholic Social Services (CSS) to place children with foster parents unless CSS agreed to include same-sex couples, in obedience to nondiscrimination requirements of city ordinance.

In an opinion joined by all of his colleagues, Chief Justice John Roberts observed that CSS "does not object to certifying gay or lesbian individuals as single foster parents or to placing gay and lesbian children," and "[n]o same-sex couple has ever sought certification from CSS."

If a same-sex couple did seek to be certified, "CSS would direct the couple to one of more than 20 other agencies in the City, all of which currently certify same-sex couples."

The court held that the city's refusal to renew CSS's foster care contract violated the First Amendment's free exercise clause by putting CSS "to the choice of curtailing its mission or approving relationships inconsistent with its beliefs."

That wasn't the end of the analysis, though, because of a 1990 Supreme Court ruling that loomed over this case: Employment Division v. Smith. In Smith, the court held that generally applicable laws do not violate the free exercise clause even if they negatively affect religious practices. In Fulton, the city argued that its prohibition on sexual orientation discrimination was such a generally applicable law.

The court disagreed because the city's nondiscrimination requirement permitted a party to seek an exemption, and "a law is not generally applicable if it ... provid[es] a mechanism for individualized exemptions."

Once a law that burdens religious exercise is deemed not generally applicable, it falls outside the scope of Smith and is thus subject to "strict scrutiny." This means that the law can only survive if it advances government interests of the highest order and is narrowly tailored to achieve those interests. More simply, "so long as the government can achieve its interests in a manner that does not burden religion, it must do so."

So every justice agreed that CSS should prevail. But three justices — Samuel Alito, Clarence Thomas and Neil Gorsuch — were ready to go further and overturn Smith, pointing out in a concurring opinion that the rule permitting "generally applicable" laws to withstand constitutional scrutiny, no matter their impact on religious exercise, is deeply problematic. For example, under Smith, the Volstead Act implementing Prohibition would have been constitutional even if it contained no exception for the sacramental wine necessary for Catholic masses. Or a ban on infant circumcision would be permissible, even if it applied to prohibit important Jewish and Muslim practices.

Because the court avoided Smith by focusing on the possibility of an exemption in Philadelphia's nondiscrimination requirement, the concurrence warned that today's decision "might as well be written on the dissolving papers sold in magic shops" because, "if the City wants to get around today's decision, it can simply eliminate the never-used exemption power."

So even in a unanimous ruling, important disagreements lurk. But even those disagreements don't align easily with our political tribalism. The author of Smith against whom conservative stalwarts Alito, Thomas, and Gorsuch were railing? Conservative judicial hero Antonin Scalia.

The rule of law does not lend itself to simplistic predictions based on which president appointed which judge. In last week's other headline ruling, Trump appointees Amy Coney Barrett and Brett Kavanaugh joined five of their colleagues in upholding Obamacare against a challenge brought by Republican-led states.

The sorting that has occurred between American conservatives and liberals maintains an ideological core, but it has morphed into something broader and deeper than ideology. In his book "Why We're Polarized," Ezra Klein points out that the two major political parties today "are sharply split across racial, religious, geographic, cultural and psychological lines," and that these identities "are fusing together, stacking atop one another."

In other words, a conflict between religious liberty and LGBT rights aligns with the more fundamental conflict between our stacked social identities. We don't need to choose a side; we already know which side we're on based on where we live, what cable news we watch, what car or truck we drive, where (and whether) we go to church, even where we shop.

The rule of law reminds us that it should not and need not be that simple. I'm confident, for example, that Justice Sonia Sotomayor and Justice Thomas do not run in the same political circles or derive their identities from the same sources. And yet they can step back from the noise, examine the facts of a situation, apply sound principles not of their own creation and agree on an outcome.

Not every case will be unanimous. But members of the Supreme Court have not given up hope that they can still reason together to resolve deeply contested issues. And if they can do that under the white-hot national spotlight, so can the rest of us.

Robert K. Vischer is dean of the University of St. Thomas School of Law. The views expressed here are his own.