The Supreme Court delivered an important victory for religious advocates Tuesday, saying states that aid private schools must include religious ones.

Chief Justice John G. Roberts Jr., writing for a conservative majority in the 5-to-4 ruling, said the Constitution’s protection of the free exercise of religion requires equal treatment for religious schools and parents who want to send their children to them.

“A state need not subsidize private education,” Roberts wrote. “But once a state decides to do so, it cannot disqualify some private schools solely because they are religious.”

The court’s majority said the Montana Supreme Court was wrong to strike down a tuition assistance program established by the state legislature in 2015. It allowed tax incentives for scholarships to private schools, including religious ones. But the state court said that ran afoul of a state constitution provision forbidding public funds from going to religious institutions.

In what advocates called a landmark ruling, Roberts said the religious protections of the U.S. Constitution prevail. It holds implications for public funding of religious institutions in other areas and continues a recent pattern of the Supreme Court erasing stark lines in the separation of church and state.

Nelson Tebbe, a religious law expert at Cornell, said the ruling moves beyond previous constitutional questions. The court “held not only that the Constitution does not prohibit a state from supporting religious schools, but also that it requires a state to include religious schools in any school choice program,” he said.

Another pattern continued: the prominence of the chief justice in the most important decisions of the Supreme Court’s term. While he has formed a majority with liberals in previous cases striking down a Louisiana abortion law and stopping the Trump administration from dismantling a program protecting undocumented immigrants, he was joined in Tuesday’s opinion by the court’s four most consistent conservatives.

The decision was a big win for school choice advocates such as Education Secretary Betsy DeVos, who favor government support for students seeking faith-based education and called the ruling a “turning point in the sad and static history of American education.”

Public school advocates said such programs take away resources that should be used to improve those systems. National Education Association President Lily Eskelsen García said it will have a “shameful and unacceptable” impact on public education.

The Trump administration supported the challenge to the Montana court’s decision and hailed the Supreme Court’s ruling.

It “removes one of the biggest obstacles to better educational opportunities for all children,” White House press secretary Kayleigh McEnany said in a statement.

“The Trump Administration believes that school choice is a civil rights issue, and that no parent should be forced to send their child to a failing school.”

Roberts was joined in the opinion by Justices Clarence Thomas, Samuel A. Alito Jr., Neil M. Gorsuch and Brett M. Kavanaugh.

The court’s liberals said that the Montana Supreme Court had eliminated any discrimination problems by ending the program and that their conservative colleagues were too anxious to fix a problem that no longer existed.

The parents who brought the case “argue that the Free Exercise Clause requires a state to treat institutions and people neutrally when doling out a benefit — and neutrally is how Montana treats them in the wake of the state court’s decision,” wrote Justice Ruth Bader Ginsburg, joined by Justice Elena Kagan. “Accordingly, the Montana Supreme Court’s decision does not place a burden on petitioners’ religious exercise.”

Justice Stephen G. Breyer said the court’s decision increases the risk of government entanglement in religion, with objecting taxpayers having to fund religious instruction.

“If, for 250 years, we have drawn a line at forcing taxpayers to pay the salaries of those who teach their faith from the pulpit, I do not see how we can today require Montana to adopt a different view respecting those who teach it in the classroom,” Breyer wrote.

Justice Sonia Sotomayor wrote separately that the ruling “weakens this country’s longstanding commitment to a separation of church and state beneficial to both.”

Roberts responded that the Montana legislature did not want the program to end.

“The Montana Legislature created the scholarship program; the Legislature never chose to end it, for policy or other reasons,” he wrote. “The program was eliminated by a court, and not based on some innocuous principle of state law. Rather, the Montana Supreme Court invalidated the program pursuant to a state law provision that expressly discriminates on the basis of religious status.”

At issue was an initiative passed by the Montana legislature in 2015 that provided dollar-for-dollar tax credits up to $150 to those who donated to scholarship programs for low-income parents to send their children to private schools.

The program made no distinction as to whether parents could use the scholarships at religious or secular schools. About 70 percent of private schools in the state are religious.

The Montana Supreme Court said that ran counter to a state constitutional prohibition on public funds for “any sectarian purpose or to aid any church, school, academy, seminary, college, university, or other literary or scientific institution, controlled in whole or in part by any church, sect, or denomination.”

The challenge was brought by the libertarian law organization Institute for Justice on behalf of Kendra Espinoza, a single mother who sends her two children to a Christian school in Kalispell, Mont.

The organization has made school choice a priority and has strategized for years to get the Supreme Court to take on “Blaine Amendments” that swept though the country in the 1800s on a wave of anti-Catholicism. Montana’s amendment was adopted in 1884, before the state was even admitted to the union.

Institute for Justice Senior Attorney Erica Smith said it was a “landmark case in education that will allow states across the country to enact educational choice programs that give parents maximum educational options.”

Espinoza, a single mother who works for a construction company, learned she had prevailed on Tuesday morning, as she prepared oatmeal for her kids. She said she wanted to be in the lawsuit because she felt strongly that her daughters should get a Christian education and worried about what they would learn in public school.

“I wanted my kids to be taught with a morals and values-based education and higher academic standards,” Espinoza said, “and mentored by teachers that love them and teach from God’s word and not just teach from the more liberal perspective.”

Montana denied that its constitutional prohibition was about religious bigotry. It was included in a rewrite of the state constitution in 1972, and was meant both to insulate religion from government intrusion and protect public schools, the state said.

Alito devoted his opinion concurring with the majority to a discussion of the Blaine Amendments. He illustrated it with an 1871 cartoon from Harper’s Weekly that, in Alito’s words, “depicts Catholic priests as crocodiles slithering hungrily toward American children as a public school crumbles in the background.”

Montana was called before a Supreme Court increasingly skeptical of stark lines between church and state. In Trinity Lutheran Church of Columbia v. Comer, a majority of justices in 2017 said Missouri could not ban a church school from requesting a grant from a state program that rehabilitated playgrounds. They have since been joined by Kavanaugh, who has signaled other such restrictions deserve the court’s attention.

Roberts described the Trinity Lutheran decision as reaching the “unremarkable” conclusion that “disqualifying otherwise eligible recipients from a public benefit ‘solely because of their religious character’ imposes ‘a penalty on the free exercise of religion that triggers the most exacting scrutiny.’ ”

But Breyer and Kagan, who agreed with the majority in that case, dissented from Tuesday’s expansion.

The case is Espinoza v. Montana Department of Revenue.

Website wins trademark case

Also Tuesday, the court ruled 8 to 1 that the U.S. Patent and Trademark Office was wrong not to let travel reservation company Booking.com register its name.

The agency had said its ban on registering trademarks for generic names prohibited the company from receiving trademark protection.

But the court said the company’s name was distinctive enough.

“Because ‘Booking.com’ is not a generic name to consumers, it is not generic,” Ginsburg wrote for the majority.

Breyer was the lone dissenter.

The case is Patent and Trademark Office v. Booking.com.

Valerie Strauss and Moriah Balingit contributed to this report.