In a case involving two Kentucky counties, McCreary County v. ACLU of Kentucky, the court said framed copies of the Ten Commandments on display in the counties' courthouses were unconstitutional.
The court then decided, in Van Orden v. Perry, that a Ten Commandments monument on the grounds of the Texas State Capitol was constitutionally acceptable.
The court's majority argued that there was a difference in the two displays.
"The First Amendment mandates government neutrality between religion and religion, and religion and non-religion," wrote Justice David Souter for the majority. In the Kentucky case, the counties had a "predominantly religious purpose."
The Texas monument, on the other hand, has "been used as part of a display that communicates not simply a religious message, but a secular message as well," said Justice Stephen Breyer.
The intention behind the monument, a 1961 donation from the Fraternal Order of Eagles, was meant to be non-religious, Breyer said.
The court said some displays of the Ten Commandments are acceptable if they are portrayed neutrally and in the context of paying tribute to the U.S.'s legal history, like the display in the Supreme Court's courtroom.
Voting was mostly along liberal-conservative lines, but Breyer joined Justices Souter, John Paul Stevens, Sandra Day O'Connor and Ruth Bader Ginsburg in voting against the constitutionality of Kentucky's displays.
The ruling is the latest event in the continuing controversy over displays of the Ten Commandments in public places.
In 1980, the Supreme Court prohibited the display of the Ten Commandments in public school classrooms. In 2003, Alabama Chief Justice Roy Moore went against a court order to move a Ten Commandments monument from Alabama's judicial rotunda; he was taken out of office.