A 40-foot cross erected as a tribute to World War I dead may continue to stand on public land in Maryland, the Supreme Court ruled Thursday, rejecting arguments that it represented an unconstitutional endorsement of religion.

The vote was 7 to 2 for the Bladensburg Peace Cross, which towers over a busy intersection on a highway just outside the District, in Prince George’s County.

But the case’s resolution prompted an outpouring of individual opinions as the court struggled to explain what should be done with displays on government property that feature religious imagery.

Justice Samuel A. Alito Jr. wrote the main opinion and said history and tradition must be taken into account when judging modern objections to monuments that were built with a secular purpose or have come to take on a new meaning.

“The cross is undoubtedly a Christian symbol, but that fact should not blind us to everything else that the Bladensburg Cross has come to represent,” Alito wrote. “For some, that monument is a symbolic resting place for ancestors who never returned home. For others, it is a place for the community to gather and honor all veterans and their sacrifices for our Nation. For others still, it is a historical landmark.

“For many of these people, destroying or defacing the Cross that has stood undisturbed for nearly a century would not be neutral and would not further the ideals of respect and tolerance embodied in the First Amendment.”

Alito was joined in deciding that the cross may remain by Chief Justice John G. Roberts Jr. and Justices Clarence Thomas, Stephen G. Breyer, Elena Kagan, Neil M. Gorsuch and Brett M. Kavanaugh.

Alito wrote that “retaining established, religiously expressive monuments, symbols, and practices is quite different from erecting or adopting new ones. The passage of time gives rise to a strong presumption of constitutionality.”

Breyer wrote to emphasize the flip side of that equation. “I see no reason to order this cross torn down simply because other crosses would raise constitutional concerns,” Breyer wrote in his concurring opinion, joined by Kagan. But he noted, “a newer memorial, erected under different circumstances, would not necessarily be permissible under this approach.”

Justices Ruth Bader Ginsburg and Sonia Sotomayor dissented, and Ginsburg emphasized her strong disagreement by reading part of her dissent from the bench. She said the court’s decision to maintain the cross-shaped monument on public land “erodes” the constitutional principle that “demands governmental neutrality.”

By honoring World War I service members with a cross-shaped memorial, the state of Maryland, she said, “places Christianity above other faiths” and sends the message to people of other faiths that “they are outsiders.”

“Making a Latin cross a war memorial does not make the cross secular. Quite the contrary, the image of the cross makes the war memorial sectarian. The Peace Cross is no exception,” Ginsburg said.

The Bladensburg Peace Cross, made of granite and cement, was built in 1925 and paid for by local families, businesses and the American Legion to honor 49 World War I veterans from Prince George’s County. But the 40-foot cross sits on a now-busy highway median owned since 1961 by a state commission that pays for its maintenance and upkeep.

The legal challenge began with the American Humanist Association, a nonprofit atheist organization that has filed similar lawsuits throughout the country.

The fight to retain the cross united often-warring Maryland officials, and they reacted enthusiastically to Thursday’s ruling. It “ensures that this memorial — a dignified tribute to those who came before us and made the ultimate sacrifice — will stand tall and proud for the ages,” Maryland Gov. Larry Hogan (R) said in a statement.

Elizabeth M. Hewlett, who chairs the Maryland-National Capital Park and Planning Commission, which owns the median on which the Peace Cross sits, said the commission plans to make repairs to the crumbling monument.

“Now that the status of the Peace Cross has been clarified, we can move forward with a plan and then secure cost estimates,” Hew­lett said.

Seven of the nine justices wrote separately in the case, but there was no dramatic change in the court’s jurisprudence in the majority opinion from Alito. Some have wanted the court to junk the “Lemon test,” from a 1971 decision that sets out standards for courts to decide when a government action crosses the line to violate the Constitution’s ban on establishment of religion.

That didn’t happen, but Alito wrote that the test “presents particularly daunting problems in cases, including the one now before us, that involve the use, for ceremonial, celebratory, or commemorative purposes, of words or symbols with religious associations.”

More relevant, Alito said, are issues such as whether a monument over time has taken on new meaning. He discussed at length how the April fire at Notre Dame Cathedral in Paris had shown that its value as a place of worship had “broadened” to become part “of the very idea of Paris and France.”

Also, when something has become a part of the landscape, he wrote, “tearing down monuments with religious symbolism and scrubbing away any reference to the divine will strike many as aggressively hostile to religion.”

It was clear at oral arguments that a majority of the justices were not eager to follow a lower court’s suggestion that the cross be moved or shed its arms to more resemble an obelisk.

Monica Miller, who argued the case for the American Humanist Association, said she was grateful the court avoided a more sweeping declaration that would have covered other public monuments and displays with religious features.

Her opponents were “hoping for a complete upheaval of the separation of church and state,” Miller said in a statement. “Fortunately, the Lemon test and decades of precedent have not been overruled in the vast majority of relevant instances.”

The liberal justices who joined in the judgment praised Alito’s ruling as eloquent and sensitive to the nation’s religious pluralism.

Breyer said he was persuaded by the specifics of the case: that crosses are a specific symbol of World War I sacrifice and that the Bladensburg Cross had stood for nearly a century without controversy.

“The Peace Cross cannot reasonably be understood as ‘a government effort to favor a particular religious sect’ or to ‘promote religion over nonreligion,’ ” he wrote, repeating earlier standards set by the court.

Kagan said she declined to join all parts of Alito’s ruling “out of perhaps an excess of caution.”

“Although I too look to history for guidance, I prefer at least for now to do so case-by-case, rather than to sign on to any broader statements about history’s role in Establishment Clause analysis,” she wrote.

Some of the court’s conservatives would have gone further in changing how the court considers such controversies.

Thomas repeated his view that the First Amendment’s words that “Congress shall make no law respecting an establishment of religion” means that states are more free to do what they want.

Gorsuch would have dismissed the case. The challenge was brought by those who said they were offended by the sight of the monument. “This ‘offended observer’ theory of standing has no basis in law,” he wrote. Ginsburg said she found that “startling” in view of the many religious-display cases brought on those grounds.

Kavanaugh wrote separately to say that the Lemon test “is not good law.” He also said he understood Jewish war veterans who in an amicus brief said the erection of a cross to denote sacrifice sends a message of exclusion.

“It would demean both believers and nonbelievers to say that the cross is not religious, or not all that religious,” he wrote. “A case like this is difficult because it represents a clash of genuine and important interests.”

If divisive at the court, not so in Maryland, where Democrats such as Attorney General Brian E. Frosh and Senate President Thomas V. Mike Miller Jr. joined Republican Hogan in urging the court to allow the cross to remain.

Bladensburg Mayor Takisha James, a Democrat, said she had received a deluge of emails and texts from excited residents.

“The community is overwhelmed with happiness,” she said. “We look at it simply as a memorial to Prince Georgians who fought on behalf of our community.”

The case is American Legion v. American Humanist Association.

Ann E. Marimow and Rachel Chason contributed to this report.