CNN  — 

The Supreme Court on Wednesday threw out two job bias lawsuits brought by teachers against their religious employers, reaffirming that religious institutions and schools have a First Amendment right to select their employees.

It’s the latest case to come before the court exploring the relationship between church and state, and in their 7-2 ruling, the justices clarified the class of employees who are barred from suing their religious employers under anti-discrimination law.

The ruling is a win for conservatives arguing in favor of what they see as religious freedom. It came the same day the court sided with the Trump administration and blocked a requirement for employers with religious or moral objections to cover contraceptives under the Affordable Care Act.

Justice Samuel Alito wrote that the First Amendment protects the right of religious institutions “to decide for themselves, free from state interference, matters of church government as well as those of faith and doctrine.”

He added that while religious institutions do not enjoy “a general immunity from secular laws” their autonomy is protected with “respect to internal management decisions.”

Alito also held that the two teachers did not have the title of “ministers” but that there is “abundant record evidence that they both performed vital religious duties.”

“They prayed with their students, attended Mass with the students, and prepared the children for their participation in other religious activities,” he said.

Justice Sonia Sotomayor, joined by Justice Ruth Bader Ginsburg, dissented. She noted that while the teachers taught religion “for a part of some days in the week” it should not “transform them automatically into ministers.”

Seven years ago, the court recognized a “ministerial exception” for the first time, holding that under the First Amendment the government could not interfere with a church’s employment decisions. The justices said that the teacher in that case could be considered a “minister.”

“Requiring a church to accept or retain an unwanted minister, or punishing a church for failing to do so,” Chief Justice John Roberts wrote for a unanimous court at the time, deprives the church “of control over the election of those who will personify its beliefs,” and “a religious group’s right to shape its own faith and mission through its appointments.”

The case concerned the scope of that decision and whether it encompassed teachers who said they have limited religious duties.

Agnes Deirdre Morrissey-Berru sought to sue Our Lady of Guadalupe School for employment discrimination. She worked as a substitute teacher for the school in California, and later as a full-time fifth- and sixth-grade teacher. One of the courses she taught daily was religion, and she was required to be Catholic and lead a daily prayer.

But during the 2014-2015 school year, she was moved to a part-time position and the next year the school did not renew her contract. The school said the decision was made because of her teaching performance, but Morrissey-Berru said the school discriminated against her based on her age.

Kristen Biel, who has since passed away, was employed at St. James School as a fifth-grade teacher, including teaching religion a few days a week, from 2013-2014. At the end of the year she informed the principal that she had breast cancer and needed time off. A few weeks later, she was told her teaching contract would not be renewed due to her “classroom management.” She sought to sue her school under the Americans with Disabilities Act. Biel’s husband is now representing her estate.

In court, lawyers for the teachers told the justices that they were lay teachers and if the schools were to prevail “it would strip more than 300,000 lay teachers in religious schools across the country of basic employment law protections.”

“It would blow a hole in our nation’s civil rights laws and our employment laws in general to say that categorical immunity applies and so schools can pay people different amounts, use race, sex, other private characteristics even when they have nothing to do with the religion and religious values at stake,” argued Jeffrey L. Fisher, one of the lawyers.

He stressed that although the teachers taught religion, courts should look at a multiple factors, including title and training before determining whether they triggered the exception.

Lawyers for the school countered that the Supreme Court previously made clear that the women would trigger the exception.

“Both of the Catholic schoolteachers here exercised important religious functions,” Eric Rassbach, an attorney at the Becket Fund for Religious Liberty, argued.

The Trump administration sided with the school along similar lines.

“Today’s important decision does not mean, as some suggest, that religious institutions are above the law or that they have a license to discriminate,” said Richard Garnett of Notre Dame Law School, who filed a brief in support of the schools.

“It means, instead, that a crucial dimension of our Constitution’s religious-freedom guarantee is that civil powers are limited to civil matters and that state lacks authority to second-guess religious decisions and doctrines,” he added.

This story has been updated.