Justice Anthony Kennedy captured the problem with the federal Defense of Marriage Act in eight words: “It seems to me there is injury here.” Yes, there is, and injured parties often go to court to seek repair, or what the Supreme Court should provide by striking down the law.

The problem with the 1996 law is that it denies to legally married gay couples federal benefits available to those in opposite-sex marriages. Recall the spirit of the debate 17 years ago. Congress did not seek mere uniformity, ensuring that all gay couples are treated the same, as the attorney defending the law reasoned in the oral argument on Wednesday. Lawmakers saw the logic of gay marriage beginning to take early hold. They hustled to express their disapproval, large, bipartisan majorities declaring that a gay marriage rated as something far less than a traditional marriage.

As Justice Elena Kagan noted, the legislation was driven “by dislike, by fear, by animus.” She added that Congress took an unprecedented step, departing from its long practice of recognizing that states govern marriage, divorce and custody, federal law following in the path of state law. For Justice Kennedy, the departure seems to bring big legal trouble, a collision “with what has always been thought to be the essence” of state authority.

Yet even worse is the consequence of the posturing and exertion of federal power — the plain violation of equal treatment under the law.

Nine states and the District of Columbia allow gay marriage. Under the Defense of Marriage Act, same-sex couples in those states are barred from receiving a large array of federal benefits. Edie Windsor, the plaintiff in the case before the high court, paid $360,000 in federal inheritance taxes after the death of the woman she married. If she had married a man, she would have gained an exemption and would not have had to pay.

Donald Verrilli, the U.S. solicitor general, arguing to overturn the federal law, explained that “the spouse of a soldier killed in the line of duty cannot receive the dignity and solace of an official notification of next of kin.” Such disparities are not just unfair. They often are cruel.

Justice Ruth Bader Ginsburg put it another way, citing what amounts to “two kinds of marriage: the full marriage, and then this sort of skim milk marriage.” Both are legal in the eyes of the nine states and the district. Yet federal law holds that couples be treated differently, one set suffering the injury Justice Kennedy noted, the other not.

Justices aren’t supposed to consider the political climate. Yet the change in attitudes about gays and gay marriages has been swift and heartening. Look at Ohio. In 2004, voters approved a ban on gay marriage. Today, according to one poll, 54 percent of Ohioans support gay marriage. The change isn’t the result of a powerful gay lobby, as Chief Justice John Roberts suggested. It reflects deepening respect for gay unions, something wholly missing in the Defense of Marriage Act.