The Supreme Court strengthened the separation of church and state Wednesday and, for once, that’s a good thing.

The “separation” most people think of was created by the Supreme Court by interpreting the First Amendment’s ban on an “establishment of religion” far too broadly. That has fueled a campaign to keep religion, and even religious people, out of government or public life.

The separation recognized in Wednesday’s 7-2 decision works the other way, however, keeping government out of decisions by religious institutions about who may teach their faith. This comes from a properly balanced interpretation of the First Amendment, which also protects the free exercise of religion.

The high court’s decision combined two cases in which Catholic schools in California each fired a fifth-grade teacher, who then sued under a federal employment discrimination law. In Our Lady of Guadalupe School v. Morrissey-Berru, the teacher said age was the real reason for her firing, while in St. James School v. Biel, the teacher claimed it was disability.

The issue in these cases was whether religious institutions, such as schools and churches, may make certain personnel decisions without government interference. Federal courts have recognized that the First Amendment creates what is often called a “ministerial exception” to employment discrimination laws regarding certain positions.

In the 2012 case Hosanna-Tabor Evangelical Lutheran Church & School v. EEOC, the Supreme Court said that this ministerial exception protects the “important … interest of religious groups in choosing who will preach their beliefs, teach their faith, and carry out their mission.”

In Hosanna-Tabor, the court was unanimous that the ministerial exception exists and why it is important, but split several ways on how to define and apply it in future cases. Should courts focus narrowly on an employee’s job title or specific credentials, look more broadly at an employee’s actual functions or duties, or rely on the religious employer’s conclusion?

The U.S. Court of Appeals for the 9th Circuit took a very narrow approach in these cases, refusing to recognize the ministerial exception.

Even though the teacher at Our Lady of Guadalupe had “significant religious responsibilities,” the appeals court said, she had a “secular” job title, no formal religious credentials, and did not “hold herself out to the public as a religious leader or minister.” The court also said that the teacher’s situation at St. James School was not exactly parallel to the one in Hosanna-Tabor.

In an opinion written by Justice Samuel Alito, the Supreme Court said Wednesday that the 9th Circuit “misunderstood our decision” in Hosanna-Tabor. Rather than following a “rigid formula,” Alito wrote, courts should consider “all relevant circumstances” and be guided by “the fundamental purpose of the [ministerial] exception.”

To make its point, the Supreme Court looked at religious education in the Catholic, Protestant, Jewish, and Islamic contexts, as well as the Church of Jesus Christ of Latter-day Saints and Seventh-day Adventists. Each of these religious communities draws a close connection between “their central purpose and educating the young in the faith.”

“What matters most,” Alito wrote, “is what an employee does … . [E]ducating young people in their faith, inculcating its teachings, and training them to live their faith are responsibilities that lie at the very core of the mission of a private religion school.”

Justice Clarence Thomas, joined by Justice Neil Gorsuch, agreed with the majority but wrote a separate opinion that echoed his position in Hosanna-Tabor. Rather than scrutinize the internal management and academic practices of religious schools, even with the guidance the court was providing, Thomas preferred simply to “defer to religious organizations’ good-faith claims that a certain employee’s position is ‘ministerial.’”

Justice Sonia Sotomayor, joined by Justice Ruth Bader Ginsburg, dissented and also took the position she did in Hosanna-Tabor. Sotomayor would restrict the First Amendment’s protection only to situations in which a religious institution fires a “leader” with formal theological training for “religious reasons.”

This is a significant decision by the Supreme Court. It reaffirms the key principle that the First Amendment provides real protection for decisions by religious institutions about how to further their religious mission.

Building on Hosanna-Tabor, the decision provides better guidance about how courts should understand and apply this aspect of religious freedom. And, unlike in Hosanna-Tabor, this time seven justices put their stamp of approval on the entire decision.