In a batch of decisions at the end of its term, the Court also ruled that the government cannot retroactively erase statutes of limitations, a blow to prosecutors in sex abuse cases. It sided with a convicted killer who had incompetent counsel in an important test of legal standards for death penalty cases.
The justices also refused to take a case concerning corporate free speech that pitted Nike against an anti-globalization activist.
In the sodomy case, Lawrence v. Texas, the court voted 6 to 3 to reverse an unpopular 17-year-old ruling in a Georgia case that upheld similar laws.
The two men at the heart of the case, John Geddes Lawrence and Tyron Garner, were each fined $200 and spent a night in jail for a misdemeanor sex charge when police forced their way into their apartment and found them having anal sex in 1998.
The men "are entitled to respect for their private lives," Justice Anthony Kennedy wrote for the majority. "The state cannot demean their existence or control their destiny by making their private sexual conduct a crime."
"In our tradition the State is not omnipresent in our home," Kennedy wrote. "Liberty presumes an autonomy of self that includes freedom of thought, belief, expression, and certain intimate conduct."
Justices John Paul Stevens, David Souter, Ruth Bader Ginsburg and Stephen Breyer agreed with Kennedy in full. Justice Sandra Day O'Connor agreed with the outcome of the case but not all of Kennedy's rationale.
CBS News Correspondent Richard Schlesinger followed the case, and reports the two men at its center see the decision as a landmark ruling for the gay community.
"We thank everyone who saw how important this case was and fought for us. We share this victory with gay people in all 50 states who are better off today than they were yesterday thanks to this ruling," Lawrence said.
Chief Justice William H. Rehnquist and Justices Antonin Scalia and Clarence Thomas dissented.
"The court has largely signed on to the so-called homosexual agenda," Scalia wrote for the three. He took the unusual step of reading his dissent from the bench.
"The court has taken sides in the culture war," Scalia said, adding that he has "nothing against homosexuals."
Thomas wrote separately to say that while he considers the Texas law at issue "uncommonly silly," he cannot agree to strike it down because he finds no general right to privacy in the U.S. Constitution.
Texas defended its sodomy law as in keeping with the state's interest in protecting marriage and child-rearing. Homosexual sodomy, the state argued in legal papers, "has nothing to do with marriage or conception or parenthood and it is not on a par with these sacred choices."
As recently as 1960, every state had an anti-sodomy law. In 37 states, the statutes have been repealed by lawmakers or blocked by state courts.
Of the 13 states with sodomy laws, four — Texas, Kansas, Oklahoma and Missouri — prohibit oral and anal sex between same-sex couples. The other nine ban consensual sodomy for everyone: Alabama, Florida, Idaho, Louisiana, Mississippi, North Carolina, South Carolina, Utah and Virginia.
Thursday's ruling apparently invalidates those laws as well.
The court "has created a broad new legal rationale for future challenges by gay rights activists," said CBS News legal analyst Andrew Cohen. "This is a major ruling that will change a lot of other laws down the road."
Cohen said the ruling could be used by gays and others to challenge a wide range of laws on the basis of a right to privacy.
Most states have repealed anti-sodomy laws. Where they still exist, they are rarely enforced. Yet the laws undermine gay equality in other areas and are fundamentally unfair, the lawyer for two gay men told the court when the case was argued in March.
"For the gay community, Lawrence is their Brown v. Board of Education, their major civil rights case," said Georgetown University law professor Richard Lazarus.
Retirement rumors are swirling around the court as the session winds down. None of the nine justices has announced plans to leave, but Rehnquist and O'Connor are considered good bets to retire soon. If either should choose to leave this year, it would give President Bush his first opportunity to choose a justice.