In a decision with both historic and practical significance for gay and lesbian couples, the Supreme Court ruled Wednesday that the federal government must recognize same-sex marriages — an outcome advocates hope will aid in their state-by-state campaign to legalize such unions nationwide.

Justice Anthony M. Kennedy's majority opinion found the 1996 Defense of Marriage Act, which defined marriage as between a man and a woman for purposes of determining eligibility for a host of federal benefits, violated equal-protection laws by relegating same-sex unions to a second-class status.

The court did not address whether the Constitution guarantees gay couples the right to marry — it left in place same-sex marriage bans in dozens of states — but the 5-4 decision for the first time granted gay couples wed in states such as Maryland federal rights equal to those enjoyed by straight spouses.

The federal law "places same-sex couples in an unstable position of being in a second-tier marriage," Kennedy wrote in one of the more expressive sections of his opinion. "It humiliates tens of thousands of children now being raised by same-sex couples."

The decision will change the lives of married gay spouses in Maryland and elsewhere in tangible ways.

They will now be able to file joint federal tax returns and receive Social Security survivor benefits. Federal employees will be able to enroll partners in health care plans offered by the government and take unpaid leave to care for a sick spouse.

Maryland is home to more than 300,000 federal workers and service members, according to the census. Nationwide, an estimated 34,000 federal employees are in same-sex relationships, including state-recognized marriages.

The landmark decision came at a turning point in societal and political attitudes toward gay marriage. Opinion polls have found the public is far more open to same-sex marriage than it was 17 years ago, when majorities of Republicans and Democrats in Congress voted to pass the act.

"The laws of our land are catching up to the fundamental truth that millions of Americans hold in our hearts: When all Americans are treated as equal, no matter who they are or whom they love, we are all more free," President Barack Obama said in a statement.

In a second case, the high court declined to rule on California's 5-year-old ban on same-sex marriages. Because a lower court had struck down Proposition 8, the court decision Wednesday had the practical effect of making the nation's most populous state the 13th to recognize same-sex marriages.

Though the court decision had no direct impact on state laws beyond California, advocates said they hope to use the political momentum they gained Wednesday to overturn bans or limitations on same-sex marriage in the more than 30 states that have them.

The next targets for gay-rights groups will be Illinois, where the legislature came close to legalizing same-sex marriage earlier this spring and might consider the issue again later this year, and New Jersey, where a same-sex marriage bill passed the legislature but was vetoed by Republican Gov. Chris Christie.

Maryland, led by Democratic Gov. Martin O'Malley, legalized same-sex marriage last year. State residents endorsed the decision in a November referendum, with 52 percent voting to keep the law on the books.

Gay Marylanders began marrying in January.

"To have the Supreme Court affirm our relationships and our marriages and our children is incredibly profound," said Carrie Evans, executive director of Equality Maryland. "For the [gay] teen who's living in Cumberland right now, I think having this message from the court that the Constitution is going to protect our marriages and our kids is incredibly significant."

Critics of same-sex marriage, including some religious leaders, condemned the rulings.

Baltimore Archbishop William E. Lori described them as "the latest in a troubling trend of decisions by lawmakers, judges, and some voters" to change the notion of marriage in the country.

The "decisions will undoubtedly have far-reaching consequences, most especially for children, and are another serious blow to the institution of marriage," he said.

Hundreds of gay rights advocates and couples, including many from Maryland, gathered on the steps of the court Wednesday, holding signs and waving rainbow flags in the humidity as they waited for the decisions.

As news of the decisions spread, the crowd erupted in cheers and many embraced.