The California Supreme Court today invalidated nearly 4,000 same-sex marriages performed in San Francisco earlier this year, ruling that the city's mayor exceeded his authority in issuing marriage licenses to gay and lesbian couples.

The state Supreme Court stressed that its ruling applies to the narrow issue of local executive authority and does not settle the more substantive question of whether a California law limiting marriage to a union between a man and a woman is constitutional.

"We hold only that in the absence of a judicial determination that such statutory provisions are unconstitutional, local executive officials lacked authority to issue marriage licenses to, solemnize marriages of, or register certificates of marriage for same-sex couples, and marriages conducted between same-sex couples in violation of the applicable statutes are void and of no legal effect," the court said in an 81-page majority opinion.

The court voted 5-2 to void the marriages. Two justices issued separate "concurring and dissenting" opinions in which they agreed that San Francisco officials exceeded their authority but said the marriages should not be declared invalid while the constitutionality of California's marriage law is the subject of pending legal challenges.

San Francisco Mayor Gavin Newsom said he disagrees with the court but would respect its order. In public comments responding to the decision, he said it was time to move "to the next step" of determining the constitutionality of the state law.

"I'm proud of what we've done," Newsom said. "Society needs to wake up and say enough's enough" and end discrimination against gays, lesbians and bisexuals, he said.

Noting that people had come to San Francisco from all over the country and a number of foreign nations to exchange marriage vows, Newsom said, "I'm proud of those 4,000 couples. I'm proud of the people . . . that had the courage to stand up on principle and say, 'I do.' "

He added, "There is nothing any court decision or politician will ever do to take that moment away." But he said "my heart is heavy" today because their legal status as married couples has been invalidated.

The marriages were performed between Feb. 12 and March 11, when the Supreme Court halted them in the face of legal challenges by conservative groups and California's attorney general, Bill Lockyer.

The same-sex marriages in San Francisco followed a court ruling in Massachusetts that allowed gay marriage.

Reacting against what he asserted was the rewriting of marriage laws through judicial activism, President Bush announced earlier this year that he would push for a constitutional amendment to define marriage, effectively banning same-sex marriages nationwide.

Newsom said today that he was confident his position would prevail, and he accused Bush of wanting to "write discrimination into the Constitution."