The Supreme Court on Wednesday ruled the Constitution’s religious liberty protections shield church schools from state and federal anti-discrimination claims filed by teachers.

The justices, by a 7-2 vote, said two elementary school teachers at Catholic schools in Los Angeles County could not sue for employment discrimination. The decision likely means religious schools, hospitals, and social services are constitutionally broadly protected from employment discrimination claims.

The decision builds on a unanimous 2012 decision holding the Constitution prevents ministers from suing their churches for employment discrimination. In that case, Hosanna-Tabor Evangelical Lutheran Church & School v. EEOC, the Supreme Court said the First Amendment’s protection of religious liberty requires a “ministerial exemption” to anti-discrimination laws when applied to religious schools.

The court cited a body of First Amendment jurisprudence stretching back decades that held in favor of the right of religious institutions to, as the Supreme Court wrote in a 1952 case, “decide for themselves, free from state interference, matters of church government as well as those of faith and doctrine.”

The cases decided Wednesday were brought by two Catholic schools hit with lawsuits by former teachers alleging discrimination in violation of the law. One of the teachers claimed her former employer had demoted her and had failed to renew her contract in order to replace her with a younger teacher in violation of anti-age discrimination laws. The other said she was discharged because she had requested a leave of absence to obtain breast cancer treatment.

Both cases were initially dismissed as barred by the ministerial exemption. Panels of the 9th U.S Circuit Court of Appeals ruled in favor of the teachers, holding that the ministerial exemption only applied to a narrow set of church school employees. The schools appealed to the Supreme Court, which rejected the 9th Circuit’s interpretation of the First Amendment’s protections as too narrow and overturned those decisions.

“The religious education and formation of students is the very reason for the existence of most private religious schools, and therefore the selection and supervision of the teachers upon whom the schools rely to do this work lie at the core of their mission,” Justice Samuel Alito wrote in the Court’s opinion. “Judicial review of the way in which religious schools discharge those responsibilities would undermine the independence of religious institutions in a way that the First Amendment does not tolerate.”

Justice Clarence Thomas, who joined the majority opinion, also wrote a concurring opinion arguing that the federal courts should have no test at all for who is covered by the “ministerial exemption” and should instead defer to religious organizations’ “goodfaith understandings of which individuals are charged with carrying out the organizations’ religious missions.” Justice Niel Gorsuch joined that opinion as well as the majority opinion.

Justices Sonia Sotomayer and Ruther Bader Ginsburg dissented. Sotomayer’s dissenting opinion accused the majority of adopting a “simplistic approach” that “strips thousands of schoolteachers of their legal protections.”

The cases are Our Lady of Guadalupe School v. Agnes Morrissey-Berru, No. 19-267, and St. James School v. Darryl Biel, as Personal Representative of the Estate of Kristen Biel, No. 19-348.

Wednesday’s decision is the latest of a string of victories for defenders of the constitutional rights of religious institutions. The Supreme Court ruled a week ago that states must allow religious schools to participate in programs that provide scholarships to students attending private schools.

In a separate case decided Wednesday, the Supreme Court sided with the Trump administration’s rules allowing businesses to opt out of providing no-cost birth control to women, something otherwise required under Obamacare, if doing so would violate the business owner’s religious or moral convictions.

That case was also decided 7-2, with Ginsburg and Sotomayer dissenting.