WASHINGTON — The Republican senator from North Carolina was blunt. “Because she’s a damn lesbian,” Jesse Helms snapped, explaining to The Washington Times why he would vote against Roberta Achtenberg, President Bill Clinton’s nominee for assistant housing secretary. Later, he clarified, calling her “a militant, activist, mean lesbian.”

That was in 1993. On Saturday, another North Carolina Republican, Richard M. Burr, stood on the Senate floor and surprised gay rights advocates by voting to repeal the military’s “don’t ask, don’t tell” policy. Mr. Burr said repeal was “generationally right” given that most Americans have grown up in a time where “they don’t think exclusion is the right thing for the United States to do.”

The two votes, 17 years apart, would suggest a kind of “We’ve come a long way baby” moment. But while public opinion has changed in favor of gay rights over the past two decades, those attitudes are often not reflected in public policy, because the views of lawmakers, polls suggest, lag behind the public, and not just among social conservatives who have long opposed elements of the gay rights agenda on moral grounds.

Polls show the public is broadly supportive of equal rights for gay men and lesbians on several issues — with the exception of the right to marry. The vast majority of Americans, nearly 90 percent, favor equality of opportunity in the workplace. More than 60 percent favored overturning “don’t ask, don’t tell” — a figure that has stood steady at least since 2005, according to the Gallup Organization, which tracks public sentiment on gay rights.

Yet the Employment Non-Discrimination Act, first proposed in the Clinton years, remains stuck on Capitol Hill, in part because lawmakers are squeamish about language in it that would protect transgender employees. The “don’t ask, don’t tell” repeal bill nearly died the week before it was passed.

Same-sex marriage is even trickier for politicians. Fewer than half of all Americans support it, which puts even supporters of gay rights, like President Obama, in a political bind. Mr. Obama supports civil unions but has opposed same-sex marriage, although he recently said that “attitudes evolve, including mine” — a hint that he might change his position.

“There have been enormous and important shifts in public attitudes, and those are a hopeful sign,” said Tobias B. Wolff, a law professor at the University of Pennsylvania who advises the Obama White House on gay rights issues. But Mr. Wolff speaks of a “political gay panic,” saying, “Even when the public is so strongly behind equality, so strongly behind the right thing, politicians are hyper-cautious.”

Ms. Achtenberg, who was ultimately confirmed as Mr. Clinton’s assistant secretary for housing — after a protracted debate — agrees. She became the first openly gay appointee to win Senate confirmation at just about the same time as Mr. Clinton put forth the “don’t ask, don’t tell” policy. She said she watched the Senate vote on Saturday at home in San Francisco and cried.

“It feels like 17 years of unfinished business,” she said.

Now that Republicans have won control of the House and increased their numbers in the Senate, many in Washington expect the political climate for gay causes to worsen. Some advocates of gay rights say their efforts will shift to the states; Maryland, New York and Rhode Island, for instance, are all contemplating legislation to legalize same-sex marriage.

Activists are also looking to the courts. In California, a federal appeals court will soon hear a challenge to that state’s same-sex marriage ban. In one big sign that attitudes have changed, a lead lawyer trying to overturn the ban is Theodore B. Olson, the conservative lawyer who was solicitor general to President George W. Bush.

In a 2009 interview with The New York Times, Mr. Olson said he regarded the case as one that could “involve the rights and happiness and equal treatment of millions of people.”

Popular culture has been a driving force behind attitudinal shifts around gay men and lesbians and gay rights, and the pace of change has been faster than during the civil rights or women’s rights movements, said Anna Greenberg, a pollster who tracks gay rights issues for the Human Rights Campaign, an advocacy group.

When Ellen DeGeneres brought her character on the ABC sitcom “Ellen” out of the closet in 1997, she shocked the nation, and her show suffered. In 2008, her wedding to Portia de Rossi was covered by People magazine, “which to me defines the mainstream,” Ms. Greenberg said.

By 2009, Dick Cheney, the Republican former vice president, was publicly supporting same-sex marriage; his daughter, Mary, is a lesbian.

Conservatives are dismayed.

“The other side is winning the war on words and the rhetoric,” said Tom McClusky, senior vice president of Family Research Council Action, the legislative arm of the conservative advocacy group. “Generationally, this is an uphill battle for us, and we realize that.”

Yet while the country may have embraced gay men and lesbians in popular culture — witness the success of movies like “Milk,” based on the life of the slain gay rights activist Harvey Milk — its political leaders are careful about that embrace. Former President Jimmy Carter recently created a stir when he said the nation was ready for a gay president. On Monday, the White House press secretary, Robert Gibbs, brushed aside a question about whether Mr. Obama shares that view.“I haven’t asked him,” Mr. Gibbs said.

Mr. Clinton, for one, learned firsthand the dangers of getting ahead of public opinion on gay rights. In 1992, he ran for president as the first major party candidate to openly court the gay vote. But when he took on the issue of gays in the military just days after his inauguration, he opened a hornet’s nest. The public was split on whether gay men and lesbians should serve openly.

“Don’t ask, don’t tell” was devised as a compromise from Mr. Clinton’s initial position, which was that the ban on service by gay men and lesbians should be lifted entirely. After Saturday’s vote, Mr. Clinton’s onetime adviser on gay rights, Richard Socarides, sent the former president an e-mail message, via an aide.

“92 campaign promise fulfilled!” Mr. Socarides wrote.

The aide, Mr. Socarides said, wrote back with a message from the former president: “Hooray! A long time coming.”