A routine House Judiciary Committee report backing the Defense of Marriage Act helped sway Congress in its favor 17 years ago. But on Wednesday, that same report drew gasps when Justice Elena Kagan read key excerpts.

“Congress decided to ‘reflect and honor a collective moral judgment’ and to express ‘moral disapproval of homosexuality,’ ” Kagan said, provoking an audible reaction from the audience.

It was a dramatic moment in the closely watched deliberations over a key section of the Defense of Marriage Act, which bars the federal government from recognizing same-sex unions. But it was also a moment that underscored how drastically the tenor of the debate over gay marriage and homosexuality has changed since then, not only in public opinion but in official circles in Washington.

Congress overwhelmingly supported the Defense of Marriage Act in 1996, even though same-sex marriage was not yet legal anywhere in the United States. As recently as the 2000s, it was viewed as politically safer for most candidates to oppose same-sex marriage than to support it.

The picture today is notably different.

Last year, President Obama became the first sitting president to endorse same-sex marriage, a decision that did not thwart his re-election. After consistently losing at the ballot box, gay-marriage advocates logged their first referendum victories in November when voters supported it in Maine, Maryland and Washington. More recently, a cascade of elected officials have announced their support for same-sex unions, including some senators from conservative states such as North Carolina and Missouri.

When DOMA was under consideration, Congress asked the Justice Department three times if it was constitutional, Paul Clement, the lawyer arguing in favor of the law, told the justices Wednesday. All three times, the answer Congress received was yes.

But now, Obama’s Justice Department has deemed DOMA unconstitutional and has taken the unusual step of declining to defend it in court. And one of the chief critics of the law to emerge recently is Bill Clinton, the very president who signed it into law.

Not surprisingly, the shift has moved in tandem with public opinion.

A recent Washington Post-ABC News poll found that support for legal gay marriage has hit an all-time high at 58 percent, up 21 points over the last decade alone.

The reason behind that shift came up during Wednesday’s hearing. Chief Justice John Roberts Jr. suggested that it was at least partly the result of a long-term lobbying campaign by proponents.

“As far as I can tell, political figures are falling over themselves to endorse your side of the case,” he said to Roberta Kaplan, the lawyer arguing against DOMA.

Kaplan countered that gays historically have not had much political power. And she argued that the change “comes from a moral understanding today that gay people are no different, and that gay married couples’ relationships are not significantly different from the relationships of straight married people.”

As the case has moved through the courts, gay-rights activists have repeatedly invoked the 1996 House judiciary report to show that “the reason it was passed was to discriminate against gays and lesbians,” said Brian Moulton, legal director for the Human Rights Campaign, a gay-advocacy group.

In response to Kagan, Clement allowed that “a couple of legislators may have had an improper motive.”

He said there were other reasons, including “democratic self-governance,” that were also cited and that should justify upholding the law.

Roberts appeared skeptical that prejudice played a major role. “That was the view of the 84 senators who voted in favor of it and the president who signed it?” he asked Solicitor General Anthony Verrilli. “They were motivated by animus?”

No, Verrilli replied. “But whatever the explanation, whether it’s animus, whether it’s that more subtle, more unthinking … kind of discrimination, (DOMA) is discrimination,” he said.