The Supreme Court struck down Texas's ban on private consensual sex between adults of the same sex yesterday, in a landmark victory for gay rights that enshrined for the first time a broad constitutional right to sexual privacy.

A five-justice majority of the court ruled that the state had violated the "liberty of the person both in its spatial and more transcendent dimensions" when it fined two Houston men for engaging in anal sex in their home almost five years ago.

Beginning in almost nervous tones, his chin propped on his right hand, Justice Anthony M. Kennedy seemed to gather momentum as he read an opinion as broad in its constitutional vision as any ever issued by the court.

"It is a promise of the Constitution that there is a realm of personal liberty which the government may not enter," he said.

The case involved not minors or prostitutes, Kennedy said in his written opinion, but "two adults who, with full and mutual consent from each other, engaged in sexual practices common to a homosexual lifestyle. The petitioners are entitled to respect for their private lives. The State cannot demean their existence or control their destiny by making their private sexual conduct a crime."

Justices John Paul Stevens, David H. Souter, Ruth Bader Ginsburg and Stephen G. Breyer joined Kennedy's opinion.

The ruling was anything but the narrow, cautious result many had expected in one of the most sensitive cases of the term. Its logic seemed to be not just that the Constitution prohibits the government from regulating homosexual activity, but that the Constitution protects any sexual activity between consenting adults, unless the government can show that it has a legitimate interest in controlling it.

The court's decision that expressing moral disapproval of homosexuality is not a good enough reason to criminalize consensual homosexual conduct -- which is specifically banned in only four states -- would seem to imply that the nine seldom-enforced state laws banning both homosexual and heterosexual sodomy are also unconstitutional, legal analysts said. The court's decision also seemed likely to prompt challenges to such policies as the military's ban on open homosexuality, as well as a broader assertion of equal rights for gays in such areas as child custody and employment.

As advocates of gay rights celebrated what they called a historic victory, and opponents condemned what they viewed as a judicial decree against traditional values, it was unclear whether the court's decision had resolved a national debate or reignited it.

On the court itself, Kennedy's opinion evoked forceful opposition, as Justice Antonin Scalia read his dissenting opinion in a voice sometimes tinged with scorn for Kennedy's arguments.

"Today's opinion is the product of a Court, which is the product of a law-profession culture, that has largely signed on to the so-called homosexual agenda, by which I mean the agenda promoted by some homosexual activists directed at eliminating the moral opprobrium that has traditionally attached to homosexual conduct," Scalia wrote. His opinion was joined by Chief Justice William H. Rehnquist and Justice Clarence Thomas.

Justice Sandra Day O'Connor also voted to strike down the law, but for different reasons. In a separate opinion, she explained that she objected to it because it violated the constitutional guarantee of equal treatment under the law. The state may not punish oral and anal sex between homosexuals while permitting the same conduct between heterosexuals, she wrote.

The decision overruled the court's 17-year-old ruling upholding Georgia's since-repealed sodomy law, which banned the act among homosexuals and heterosexuals. In that case, known as Bowers v. Hardwick, the court said the law did not violate the constitutional right to privacy that the court had endorsed in previous cases involving contraception and abortion.

Bowers has been cited by lower federal courts in upholding the military's ban on open homosexuality in the ranks.

"The military's policy will definitely be harder to defend after this case," said Walter Dellinger, a former acting solicitor general in the Clinton administration. "But it's not determined by this case because of rather extraordinary deference the court has given to the government in matters related to the military."

Gay rights advocates and civil libertarians still chafe at the language of Justice Byron R. White's majority opinion in Bowers, which said that "to claim that a right to engage in such conduct is 'deeply rooted in this Nation's history and tradition' or 'implicit in the concept of ordered liberty' is, at best, facetious."

That case was decided 5 to 4, with Justice Lewis F. Powell Jr. wavering until the last minute before joining the majority. Powell, who, like White, is now deceased, later said he had reread the case and "thought the dissent had the better of the arguments."

O'Connor made clear that she decided yesterday's case on a separate basis because she saw no need to retract the vote she cast with the Bowers majority.

But Kennedy, who was not on the court in 1986, wrote yesterday that Bowers "does not withstand careful analysis.

"Its continuance as precedent demeans the lives of homosexual persons," he wrote. "Bowers was not correct when it was decided, and it is not correct today."

Citing the court's line of privacy-rights cases, beginning with the 1965 ruling giving married couples a constitutional right to contraception and continuing through Roe v. Wade in 1973, Kennedy wrote that the court "misapprehended the claim of liberty" in the Bowers case.

Moreover, he argued, there is no longstanding American tradition of criminalizing consensual homosexual conduct, as the court assumed in Bowers.

Far more relevant, Kennedy wrote, is "an emerging awareness that liberty gives substantial protection to adult persons in deciding how to conduct their private lives in matters pertaining to sex," as well as the recent evolution in American opinion that has led to the repeal of legal bans on homosexual conduct in all but four states -- Texas, Kansas, Oklahoma and Missouri. He also noted that the European Court of Human Rights has rejected the principles of Bowers.

Kennedy's opinion spent little time rebutting Scalia's contention that the decision opens the door to a constitutional right to same-sex marriage.

He noted simply that the case "does not involve whether the government must give formal recognition to any relationship that homosexual persons seek to enter." But this came after a passage in which Kennedy noted that "our laws and tradition afford constitutional protection to personal decisions relating to marriage" and that "persons in a homosexual relationship may seek autonomy for these purposes, just as heterosexual persons do."

Elizabeth Birch, executive director of the Human Rights Campaign, a leading gay rights organization, said: "This is an historic day for fair-minded Americans everywhere. This ruling opens the door for new advances toward full equality."

Virginia Attorney General Jerry W. Kilgore (R) expressed disappointment with the ruling, which he said invalidates a state statute banning oral and anal sex between consenting gay and heterosexual couples. "As one who believes that the courts are to interpret and not create law, I disagree with the ruling and am always disappointed when a court undermines Virginia's right to pass legislation that reflects the views and values of our citizens," he said in a statement.

Scalia began his dissent by discussing Roe, chiding Kennedy for his willingness to overrule Bowers when, in 1992, Kennedy joined a 5 to 4 decision that ruled that overturning Roe would be too disruptive for society and damaging for the court's stature.

Scalia's dissent made the case that the majority had, indeed, "dismantle[d] the structure of constitutional law that has permitted a distinction to be made between heterosexual and homosexual unions," as well as the enforcement of laws against bestiality, adultery and adult incest.

"This case 'does not involve' the issue of homosexual marriage only if one entertains the belief that principle and logic have nothing to do with the decisions of this Court," he wrote. "Many will hope that, as the Court comfortingly assures us, this is so."

Scalia charged that the majority's allegiance to "the law profession's anti-anti-homosexual culture" had blinded it to what he said was the fact that "many Americans do not want persons who openly engage in homosexual conduct as partners in their business, as scoutmasters for their children, as teachers in their children's schools, or as boarders in their home. They view this as protecting themselves and their families from a lifestyle that they believe to be immoral and destructive."

Scalia did not himself endorse such views, but rather said that, if the majority objects to homosexuality on moral grounds and wants to outlaw it, that is a manifestation of democracy, not discrimination.

Yesterday's case, Lawrence v. Texas, No. 02-102, began almost by accident. On the night of Sept. 17, 1998, Harris County sheriff's officers entered an apartment in Houston, looking for what a neighbor had told them was a man with a gun "going crazy." Instead, they found the tenant, John Geddes Lawrence, having sex with Tyron Garner.

The person who called the police was convicted of filing a false report -- but Lawrence and Garner were also booked and jailed overnight. They were each fined $200 and ordered to pay $141.25 in court costs. The Texas appeals courts rejected their previous appeals.

Lead attorney Ruth Harlow, legal director at Lambda Legal, celebrated the decision with her legal team, Bill Hohengarten, left, and Paul Smith.The Rev. Rob Schenck of the National Clergy Council in Washington leads a prayer with the Rev. Ken Wilde, right, of the National Prayer Center in Washington, and Michael Summers of Bend, Ore., who is working with the center. The three oppose the ruling.Tyron Garner, left, and John Geddes Lawrence are hugged by a well-wisher yesterday after a rally in Houston.