WASHINGTON — The U.S. Supreme Court seemed to be leaning on Wednesday toward striking down a law that denies federal benefits to legally married same-sex couples in a move that would reflect a shift in Americans’ attitudes about gay marriage.

In a second day of oral arguments on same-sex marriage, a majority of the court raised serious concerns with the Defense of Marriage Act, or DOMA, enacted in 1996 under President Bill Clinton.

Arguments over the last two days on the DOMA case and a separate one challenging California’s ban on gay marriage marked the high court’s first foray into a delicate and divisive political, religious and social issue in the United States as polls indicate growing public support for same-sex marriage.

In theory, the cases have the potential for the court to take a significant step toward endorsing gay marriage as it gains support in some parts of the country. Based on the arguments, however, a partial victory for gay rights activists seems more likely than the sweeping declaration of same-sex marriage rights they had hoped for.

As demonstrators rallied outside the Supreme Court building for a second day, Justice Anthony Kennedy, a potential swing vote, showed a willingness to invalidate DOMA, which denies married same-sex couples access to federal benefits by defining marriage as between a man and a woman.

He warned of a “real risk” that the law infringes on the traditional role of the states in defining marriage.

A conservative, Kennedy is viewed as a key vote on this issue in part because he has twice authored decisions in the past that were viewed as favorable to gay rights.

In contrast to the ambivalent approach they displayed on Tuesday in arguments about California’s Proposition 8 gay marriage ban, the nine justices seemed willing to address the substantive issue in the DOMA case, while also eyeing procedural questions.

The court is not expected to rule on the two cases until the end of June. If the justices were to strike down DOMA, legally married gay couples would be winners because they would have improved access to federal benefits, such as tax deductions.

Justices gave a strong indication they might resolve the Proposition 8 case on procedural grounds, but even that would be viewed as a win for gay rights activists as same-sex marriages in California would likely resume.

What appears highly unlikely is a sweeping declaration of a right for gay people to marry, a possible option only in the California case.

Overall, a majority of the justices made it clear that, while they might not impede the recent movement among some states toward gay marriage, they were not willing to pave the way either.

Nine states now recognize gay marriage, while 30 states have constitutional amendments banning it and others are in between.

On several occasions over the two days, the justices’ own remarks illustrated how quickly attitudes have changed in favor of gay marriage.

During Tuesday’s arguments, Justice Antonin Scalia, a conservative, questioned whether there was sufficient data to show that children are not harmed if raised by same-sex couples. Likewise, Justice Samuel Alito noted the concept of gay marriage is “newer than cellphones and the Internet.”

Offering a liberal perspective, Justice Elena Kagan prompted murmurs of surprise from onlookers on Wednesday when she quoted from a U.S. House of Representatives report written less than two decades ago, at the time DOMA was enacted, that referenced “moral disapproval” of gay marriage.

As attention turned to DOMA on Wednesday, Kennedy made it clear where he stood, referring to DOMA as “inconsistent” because it purports to give authority to the states to define marriage while limiting recognition of those determinations.

His states’ rights concerns were echoed by two of the liberal members of the bench, Kagan and Justice Sonia Sotomayor.

“What gives the federal government the right to be concerned at all about what the definition of marriage is?” Sotomayor said.

Justice Ruth Bader Ginsburg and Justice Stephen Breyer also raised concerns about the law.

Ginsburg stressed how important federal recognition is to any person who is legally married.

“It affects every area of life,” she said.

Comparing marriage status with types of milk, Ginsburg said that a gay marriage endorsed by a state, but not recognized by the federal government, creates two types of marriage, “full marriage, and then this sort of skim milk marriage.”

If the court rules on the states’ rights issue, the justices could strike down the law without deciding the bigger question of whether DOMA violates the U.S. Constitution’s guarantee of equal protection under the law.

On that issue, Kagan spoke of a “red flag” that indicates Congress passed DOMA with the intent of targeting a group that is “not everyone’s favorite group in the world.”

Various groups are calling for DOMA to be struck down, such as the Business Coalition for DOMA Repeal, whose members include Marriott International Inc., Aetna Inc., eBay Inc., and Thomson Reuters Corp., the corporate parent of the Reuters news agency.

Separately, several conservative justices criticized Obama and his Justice Department for not defending the marriage law in court.

Chief Justice John Roberts questioned whether Obama had “the courage of his convictions” for continuing to enforce DOMA while calling it invalid.