On Nov. 4, 2009, a tearful, dispirited crowd gathered on the steps of Portland City Hall, trying to come to terms with their disappointing loss the previous day in the state’s first same-sex marriage referendum.

Gay couples and their supporters were told to keep on fighting, that history was on their side and that the only way they could lose would be to quit. They said it, but at the time it seemed hard to believe.

But the events since that rally would surprise even the optimists. The people of Maine reversed themselves and passed a marriage equality law last year along with voters in Washington and Maryland.

Now 12 states, the District of Columbia and two Native American tribes recognize same-sex marriages. The tide of public opinion has continued to rise, with everyone from President Obama to former Vice President Dick Cheney agreeing that the government should not punish people because of who they love.

And now the highest court in the land has issued a pair of opinions that put full equality for same-sex couples within reach.

The court struck down part of the misnamed Defense of Marriage Act, which prevented the federal government from recognizing the marriages of couples married in states like Maine that do not discriminate.

That affects about 1,000 places in federal law where marital status is mentioned, including the tax code and Social Security.

The court did not find a constitutional right to marry, so same-sex couples in states that do not recognize their marriages won’t benefit from this ruling.

And Maine couples who are transferred by their employer to a state that does not have same-sex marriage will have to chose between their job and their rights. Neither situation is tolerable.

But that’s a conversation for another day. Today, Mainers can think about what the ruling does accomplish.

It may not recognize a right to marry, but the majority opinion, written by Justice Anthony Kennedy, finds that the federal government does not have the right to burden and demean these couples and their children by taking away their rights.

And Kennedy took a major argument made by DOMA supporters and turned it on its head. They say that DOMA was needed to protect children of same-sex couples, but the justice rightly pointed out that children in these families are hurt when their parents can’t marry. “The law in question makes it even more difficult for the children to understand the integrity and closeness of their own family and its concord with other families in their community and in their daily lives,” he wrote.

There is still a lot of work to do to achieve equal rights for lesbian, gay, bisexual and transgender Americans, and just like the crowd outside City Hall four years ago, they should not give up.

But Wednesday’s ruling was a major milestone in this civil rights struggle and one worth celebrating.