WASHINGTON — A sharply divided Supreme Court on Monday upheld the constitutionality of displaying the Ten Commandments on government land, but drew the line on displays that promote religion, saying they violated the doctrine of separation of church and state.

The high court said displays of the Ten Commandments — like their own courtroom frieze — are not inherently unconstitutional. But each exhibit demands scrutiny to determine whether it goes too far in amounting to a governmental promotion of religion, the court said in a case involving Kentucky courthouse exhibits.

In that 5-4 ruling, and another ruling involving a granite monument of the Ten Commandments on the grounds of the Texas Capitol, Justice Sandra Day O’Connor was the swing vote. The second ruling, likewise, was 5-4.

In a stinging dissent to the ruling involving Kentucky’s courthouse exhibits, Justice Antonin Scalia declared: “What distinguishes the rule of law from the dictatorship of a shifting Supreme Court majority is the absolutely indispensable requirement that judicial opinions be grounded in consistently applied principle.”

Fine line on neutralityThe justices voting on the prevailing side in the Kentucky case left themselves legal wiggle room, saying that some displays inside courthouses would be permissible if they’re portrayed neutrally in order to honor the nation’s legal history.

But framed copies in two Kentucky courthouses went too far in endorsing religion, the court held. Those courthouse displays are unconstitutional, the justices said, because their religious content is overemphasized.

In contrast, a 6-foot-granite monument on the grounds of the Texas Capitol — one of 17 historical displays on the 22-acre lot — was determined to be a legitimate tribute to the nation’s legal and religious history.

“Of course, the Ten Commandments are religious — they were so viewed at their inception and so remain. The monument therefore has religious significance,” Chief Justice William Rehnquist wrote for the majority in the case involving the display outside the state capitol of Texas.

“Simply having religious content or promoting a message consistent with a religious doctrine does not run afoul of the Establishment clause,” he said.

Kentucky rulingWriting for the majority in the Kentucky case, Justice David Souter said that “the touchstone for our analysis is the principle that the First Amendment mandates government neutrality between religion and religion, and between religion and nonreligion.”

“When the government acts with the ostensible and predominant purpose of advancing religion, it violates the central Establishment clause value of official religious neutrality,” he said.

Souter was joined in his opinion by other members of the liberal bloc — Justices John Paul Stevens, Ruth Bader Ginsburg and Stephen Breyer, as well as O’Connor.

In his dissent, Scalia argued that Ten Commandments displays are a legitimate tribute to the nation’s religious and legal history.

“The Commandments have a proper place in our civil history,” he wrote.

Kentucky officials may have had a religious purpose when they originally posted the Ten Commandments display by itself in 1999. But their efforts to dilute the religious message since then by hanging other historical documents in the courthouses made it constitutionally adequate, Scalia said.

He was joined in his opinion by Chief William Rehnquist, as well as Justice Anthony Kennedy and Clarence Thomas.

The Bush administration, via acting Solicitor General Paul Clement, argued against a strict First Amendment wall between church and state.

Ten Commandments displays should be allowed on government property because they pay tribute to America’s religious and legal history, he argued in court. “The idea of having a fence around the Ten Commandments to make clear the state has nothing to do with it, I think that is bending it too far,” said Clement.

David Friedman, an attorney for the American Civil Liberties Union who challenged the courthouse displays, countered: “An assertion that the Ten Commandments is THE source, THE foundation of our legal system ... that is simply wrapping the Ten Commandments in the flag, and that’s endorsement.”

In their comments and questions from the bench, justices were reluctant to adopt a blanket ban on such displays. They struggled to formulate a clear constitutional rule that could determine the fate of thousands of religious symbols on public property around the country, including one in their own courtroom featuring Moses holding the sacred tablets.

Scalia noted that legislative proclamations and prayer invoking God’s name are permissible. “I don’t see why the one is good and the other is bad,” he said.

Texas case backgroundDuring oral arguments in the Texas case, Erwin Chemerinsky, a lawyer representing a man who sought the removal of the tablet, told the justices the display is a “religious symbol.” The prominence of the display on the capitol grounds and the fact that so many of the commandments deal with God “does promote religion,” he maintained.

Texas Attorney General Greg Abbott, in his court filing, wrote that “countless monuments, medallions, plaques, sculptures, seals, frescoes, and friezes — including, of course, the Supreme Court’s own courtroom frieze — commemorate the Decalogue (Ten Commandments). Nothing in the Constitution requires these historic artifacts to be chiseled away or erased.”

Chemerinsky countered that “the government’s symbolic endorsement of religion is most obvious from the content of the monument itself. In large letters, the monument proclaims ’I AM the LORD thy God.”’

Ten Commandments monuments are common in town squares, courthouses and other government-owned land around the country.

At issue was whether they violate the First Amendment ban on any law “respecting an establishment of religion,” or simply represent a secular tribute to America’s legal heritage.

The question has sparked dozens of heated legal battles, including one in Alabama by Roy Moore. He lost his job as chief justice a year ago after defying a federal order to remove a 5,300-pound Ten Commandments monument he had installed in the state courthouse.

Poll: Most Americans back displaysAn AP-Ipsos poll taken in late February found 76 percent supportive of and 23 percent opposed to Ten Commandments displays.

Past polling has found majority support for the general concept of separation of church and state. That sentiment is not always reflected when people are asked about specific cases.

Support for the Ten Commandments displays was strong among most groups in the AP poll of 1,000 adults conducted by Ipsos-Public Affairs Feb. 22-24. The margin of sampling error was plus or minus 3 percentage points.

Older adults were more likely to feel the Ten Commandments should be allowed on government property. People with only a high school education or some college were more likely to favor allowing the display of the Ten Commandments than those with college degrees.

People in the Midwest and South were more likely than those in other regions to favor allowing such displays.

Earlier rulingsIn the Texas case, the Fraternal Order of Eagles donated the exhibit to the state in 1961, and it was installed about 75 feet from the Capitol in Austin. The group gave thousands of similar monuments to American towns during the 1950s and ’60s, and those have been the subject of multiple court fights.

Two Kentucky counties, meanwhile, hung framed copies of the Ten Commandments in their courthouses and added other documents, such as the Magna Carta and the Declaration of Independence, after the American Civil Liberties Union challenged the display.

While one lower court found the Texas display to be predominantly nonreligious because it was one of 17 monuments in a 22-acre park, another court struck down the Kentucky displays as lacking a “secular purpose.” Kentucky’s modification of the display was a “sham” for the religious intent behind it, the Cincinnati-based 6th U.S. Circuit Court of Appeals ruled.

The last time the Supreme Court weighed in on the issue was 1980, when it struck down a Kentucky law requiring Ten Commandments displays in public classrooms. Since then, more than two dozen courts have ruled in conflicting ways on displays in various public contexts.

Justices have outlined several different tests in recent years to determine their constitutionality:

Secular purpose; was there religious motive?

Endorsement; do they show a government neutrality toward religion?

Coercion; do they place impermissible pressure, such as school prayer?

Historical practice; are they part of the “fabric of our society,” such as legislative prayer?

The Supreme Court frieze, for instance, depicts Moses and the tablets as well as 17 other figures including Hammurabi, Confucius, Napoleon and Chief Justice John Marshall. Because it includes secular figures in a way that doesn’t endorse religion, the display would be constitutional, Justice John Paul Stevens suggested in a 1989 ruling.