The California Supreme Court on Thursday set the stage for what promises to be extended legal warfare over same-sex weddings, voiding thousands of gay marriages conducted in San Francisco earlier this year and finding that city officials overstepped their power when they allowed the couples to exchange vows at City Hall.

As expected, the Supreme Court unanimously decided San Francisco Mayor Gavin Newsom did not have the legal authority to issue marriage licenses to 4,000 gay couples in open defiance of California laws that restrict marriage to a man and woman. A separate 5-2 vote to void the unions was applauded by gay-marriage opponents but prompted tearful disappointment among many couples who participated in the unprecedented monthlong same-sex wedding spree in February and March.

But the Supreme Court went to great lengths to emphasize that its decision was limited to the power of a local official to flout statewide laws, not the broader question of whether California’s ban on gay marriage is unconstitutional.

“Our decision in this case is not intended, and should not be interpreted, to reflect any view on that issue,” Chief Justice Ronald George wrote for the court.

The broader constitutional challenge to California’s ban on gay marriage is already under way and both sides of the issue are girding for that legal fight as the ink dried on Thursday’s ruling. Several lawsuits have been consolidated in San Francisco Superior Court, filed by San Francisco, various civil rights groups and same-sex couples.

That case is expected to be decided later this year by a trial judge and eventually force the state Supreme Court to address the heart of the legal battle, although the issue is unlikely to reach the justices for another year.

The legal fine points were small consolation to thousands of gay couples who have known that their right to marry might be short-lived in the courts.

Dozens of couples, some wearing wedding dresses and tuxedos, gathered outside the Supreme Court’s headquarters in San Francisco to await word. Their $82 fees will be refunded; their licenses are now just souvenirs.

Opponents of same-sex marriage praised the ruling as a victory for preserving what they consider traditional marriage.

“It is a recipe for disaster what they did and I think the state Supreme Court rightly reigned them in,” said Jordan Lorence, who argued the case for the Alliance Defense Fund, an Arizona-based Christian legal organization opposed to same-sex marriage.

The mood in the gay community was far more somber than six months ago, when hundreds of couples, including well-known figures such as Rosie O’Donnell, poured into City Hall each day for marriage certificates. Those weddings sparked a nationwide debate over gay marriage and injected a hot-button social issue into the presidential campaign.

“We’ve been able to right past wrongs and this is another example of one wrong that hopefully will be righted,” Molly McKay, executive director of Marriage Equality who wed her longtime partner in February, said outside City Hall.

By evening, same-sex marriage supporters were holding rallies in downtown San Francisco, as well as in Santa Cruz, vowing to press ahead in the courts.

At a San Francisco City Hall news conference, a defiant Newsom said his “heart was heavy” but that he expected the decision. Newsom and City Attorney Dennis Herrera said they were preparing to move forward in September with their central arguments in favor of legalizing gay marriage.

Newsom also made it clear that the ruling would not minimize the impact of San Francisco’s gay marriage experiment.

“We decided to challenge the law,” he said. “We decided more importantly to put a human face on discrimination.”

Foes of same-sex marriage acknowledged that the legal battle is far from over.

The Alliance Defense Fund joined California Attorney General Bill Lockyer in asking the state Supreme Court to put a halt to the San Francisco weddings. The justices in March blocked San Francisco from continuing to issue the licenses while it reviewed the case.

“We didn’t pick this fight,” Lockyer said. “I’m not an opponent of same-sex marriages, but I have a duty to defend the law and so does the court.”

Newsom and city lawyers argued that they were legally obligated to grant the licenses to same-sex couples because they believe the state’s ban on gay marriage is a violation of equal protection rights. But their argument had little traction in the Supreme Court, which warned that allowing local officials like Newsom to make such judgments would lead to “confusion and chaos” in enforcing state laws.

If San Francisco wanted to challenge state marriage laws, the court said, city officials could have sought a judge’s order before issuing the licenses. As a result, the majority of the justices agreed that they had no choice but to void the licenses because “it would not be prudent or wise to leave the validity of those marriages in limbo for what might be a substantial period of time.”

Justices Joyce Kennard and Kathryn Mickle Werdegar dissented, saying they would have left the licenses alone while the broader legal challenges unfold in the lower courts.

“I’m grateful two of the justices in particular understood the humanity at stake here,” said Kate Kendell, a staff lawyer with the National Center for Lesbian Rights, which is challenging California’s same-sex marriage ban.

Dozens of similar legal challenges have sprouted across the country since Newsom began allowing gay couples to tie the knot Feb. 12, shortly after the Massachusetts Supreme Court broke new ground by allowing the nation’s first same-sex marriages.

A Washington state judge recently found that state’s gay marriage ban unconstitutional. But the marriages have also sparked a backlash in numerous states where voters are slated in November to consider bans on same-sex weddings. Missouri last week voted to ban same-sex marriage.

Critics of same-sex marriage warn that if they lose in the courts in California, they will mobilize an effort to get the issue before voters.

“We see this as a sanctity and a holiness issue, not a civil rights issue,” said David Sawkins, one of a group of evangelical ministers who had threatened a recall effort after the San Jose City Council voted to recognize employees’ same-sex marriages.

More in News

SAN JOSE -- Grenades were discovered at an estate sale Monday, prompting the evacuation of about 10 homes near the San Jose Country Club, according to the Santa Clara County Sheriff's Office. Deputies were called to the 300 block of Gordon Avenue, near Greenside Drive, about 4:10 p.m., said Sgt. Rich Glennon. Get breaking news with our free mobile app....