WASHINGTON — The Supreme Court concluded its work for this session on Monday siding with religious institutions in a major church-state decision.

The court ruled 7-2 that religious institutions may not be excluded from state programs with a secular intent — in this case, making playgrounds safer.

Missouri's state constitution, like those in about three dozen states, forbade government from spending any public money on "any church, sect, or denomination of religion."

Trinity Lutheran Church in Columbia, Mo., wanted to participate in a state program that reimburses the cost of rubberizing the surface of playgrounds. But the state said that was not allowed. The exclusion has raised big questions about how to uphold the Constitution's prohibition on government support for religion without discriminating against those who are religious.

Missouri's state constitution, similar to those of about three dozen states, directs that "no money shall ever be taken from the public treasury, directly or indirectly, in aid of any church, sect, or denomination of religion."

Chief Justice John Roberts, who authored the opinion, wrote, "The exclusion of Trinity Lutheran from a public benefit for which it is otherwise qualified, solely because it is a church, is odious to our Constitution . . . and cannot stand."

The two dissenting votes came from Justices Ruth Bader Ginsburg and Sonia Sotomayor.

In New Jersey, disputes over public funding and religious schools have emerged in recent years. The state constitution prohibits the use of taxpayer money for places of worship, and also stipulates that public money be used for public, not private, purposes.

The ACLU's New Jersey chapter sued the state in 2013 over plans to award $11 million in grants to Beth Medrash Govoha, a Lakewood school that trains Orthodox Jewish men to be rabbis, to be used for a library and research center, and to the Princeton Theological Seminary, which is affiliated with the Presbyterian Church and planned to use the funds to update library information technology and remodel a conference room.

State officials argued that the spending should be allowed because it would not directly fund worship-related purposes, and that the proposed projects were secular.

Last year, a state appeals court sided with the ACLU, ruling that the grants were unconstitutional. The state Attorney General's office appealed; the case is to go before the state Supreme Court this fall.

Ed Barocas, legal director for ACLU-NJ, said he didn't believe Monday's ruling would impact his organization's lawsuit because the grants in New Jersey were awarded to educational facilities that actively train students in religious studies.

"The money would be used for education for religious purposes," he said. "With Trinity Lutheran, the U.S. Supreme Court was dealing with a grant to be used for a secular purpose."

At oral argument, the lawyer defending the Missouri law seemed to face an uphill battle in defending the exclusion of church groups from a program with only a secular goal — making playgrounds safer — and for which Trinity's Learning Center would have been approved had it been a secular preschool.

Some states with the same restriction as Missouri already allow churches to participate in programs that are generally applicable to the public and are for secular benefits such as health and safety.

Adding a twist to the case, Missouri now does as well. The state's new Republican governor, Eric Greitens, announced just before the April oral argument that he was reversing the policy that denied Trinity's application in 2012 and that churches are now eligible to participate.

The state's new attorney general agrees, and a private attorney was appointed by the state to defend its old policy.

The case has been pending for a very long time. The court agreed to hear it in January 2016, just before the sudden death of Justice Antonin Scalia.

Apparently fearing a deadlock, the court postponed a hearing until it had a full nine members in April.

The case is Trinity Lutheran Church of Columbia v. Comer.

Staff writer Allison Steele contributed to this article.