California's Supreme Court has annulled about 4,000 gay marriages that took place in San Francisco.
Gay couples flocked to San Francisco to get married
The court ruled that San Francisco's mayor had overstepped his authority by issuing same-sex marriage licences earlier this year.
Thousands of same-sex couples were married in the city between 12 February and 11 March, when the court issued an injunction halting the wedding spree.
Gay marriage is a controversial issue in the US.
The marriages had virtually no legal value, but they angered conservative groups, which launched legal challenges to nullify them.
The first couple to receive a marriage licence in San Francisco, Del Martin and Phyllis Lyon, expressed sadness at the judges' 5-2 ruling.
"Del is 83 years old and I am 79," Ms Lyon said. "After being together for more than 50 years, it is a terrible blow to have the rights and protections of marriage taken
away from us."
San Francisco's Mayor, Gavin Newsom, gave the go-ahead to issue marriage licences, saying current legislation was discriminatory.
His spokesman said at the time that Mayor Newsom was only following "the state constitution, which explicitly outlaws discrimination of any kind".
Bush seeks ban
In separate legal action, the city of San Francisco and gay rights groups are suing the state of California to get the law banning same-sex marriages overturned. That case will be heard later this year.
A similar case in Massachusetts led to the legalisation of gay marriage in the state. The first gay weddings began there in May.
President George W Bush strongly opposes gay marriage and is seeking to change the US constitution to specify that marriage can only take place between a man and a woman.
Gay marriage is already banned in 38 states, but lawsuits in Florida, Nebraska, New Jersey and Oregon are seeking to have it ruled legal.
Mr Bush hopes to make individual states' attempts to legalise gay married irrelevant, by outlawing it nationwide.
But last month, a constitutional amendment failed to get enough support in the Senate, delaying the issue until after the November election.
Mr Bush's Democratic challenger in the election, Senator John Kerry, opposes changing the constitution and says states should have power to decide whether to allow gay marriages. He favours civil unions, rather than gay marriage.