California's ban on same-sex marriages is unconstitutional, a San Francisco appeals court has ruled.
A statewide referendum on the issue, known as Proposition 8, imposed a bar on gay unions in November 2008 but that was overturned by a court in 2010.
Now a three-judge panel of the 9th US Circuit Court of Appeals has ruled 2-1 that the latter judgement was correct.
Supporters of the ban previously vowed to challenge the panel's decision if it went against them.
Lawyers for those backing the ban are expected to take the issue to the US Supreme Court.
Proposition 8 was a 2008 ballot measure that amended the California constitution to state that "only marriage between a man and a woman is valid or recognised in California".
Two same-sex couples challenged the measure, saying it violated their right to equal protection under the US constitution.
The 2010 ruling overturned the ban, determining it to be a violation of the civil rights of gays and lesbians.
'No such reason'
The California ban, known as Proposition 8, was passed by voters in 2008.
"Although the Constitution permits communities to enact most laws they believe to be desirable, it requires that there be at least a legitimate reason for the passage of a law that treats different classes of people differently," the ruling states.
The panel found "no such reason", the judges said in their ruling.
The 9th Circuit decision also found that there was no evidence that the judge who issued the lower court ruling, Judge Vaughn Walker, was biased, and ruled that he did not have to disclose that he was gay.
That petition was the first time the sexual orientation of a judge had been cited as grounds for overturning a court decision.
Judge Walker publicly revealed he was gay after he retired.
The 9th Circuit's decision only applies to California, although it has jurisdiction in nine states.
Opponents of same-sex marriage criticise what they see as a redefinition of the institution.
"Ever since the beginning of this case, we've known that the battle to preserve traditional marriage will ultimately be won or lost not here, but rather in the US Supreme Court," Andy Pugno, general counsel for Protect Marriage, a California group that supports Proposition 8, said in a statement.
While the proponents of Proposition 8 are expected to appeal to the US Supreme Court, they have the option of appealing first to the wider 9th Circuit, an 11-person panel.
The court put same-sex weddings in California on hold while it considered the case.
Gay marriage is legal in six states and the District of Columbia. Washington state is on track to become the seventh after legislation passed a crucial vote on 2 February.