SAN FRANCISCO -- Gays and lesbians have a constitutional right to marry in California, the state Supreme Court said Thursday in a historic ruling that could be repudiated by the voters in November.

In a 4-3 decision, the justices said the state's ban on same-sex marriage violates the "fundamental constitutional right to form a family relationship." The ruling is likely to flood county courthouses with applications from couples newly eligible to marry when the decision takes effect in 30 days.

"The California Constitution properly must be interpreted to guarantee this basic civil right to all Californians, whether gay or heterosexual, and to same-sex couples as well as to opposite-sex couples," Chief Justice Ronald George wrote in the majority opinion.

Allowing gay and lesbian couples to marry "will not deprive opposite-sex couples of any rights and will not alter the legal framework of the institution of marriage," George said.

In addition, he said, the current state law, enacted in 1977 and reaffirmed by the voters in 2000, discriminates against same-sex couples on the basis of their sexual orientation -- discrimination that the court, for the first time, put in the same legal category as racial or gender bias.

Massachusetts is the only other state whose high court has ruled in favor of same-sex marriage. Federal law denies federal benefits, such as joint income tax filing and Social Security survivors' rights, to same-sex couples who can legally marry in their states, and allows other states to deny recognition to those marriages.

Cheers go up

There were whoops of joy and hugs and tears among scores of gay rights advocates and same-sex couples Thursday outside the California Supreme Court building as word spread.

Geoff Kors, executive director of Equality California, a gay rights group, ran out of the building and screamed, "We won!" just after the decision was released at 10 a.m.

"This is an incredibly historic day," said Judy Appel, executive director of Our Families Coalition, who is raising two children with her partner in Berkeley. "I'm so thrilled, I'm so excited for what this means for my family and all Californians."

Thursday's ruling set off a celebration at San Francisco City Hall, where nearly 4,000 same-sex weddings were performed in 2004 before the state high court put a halt to the marriages while challenges to the California law worked their way through the courts. The decision has no effect on those annulments.

"We've waited over 21 years for this day, but today I can finally say I will be able to marry John, the man that I love," Stuart Gaffney, whose marriage to John Lewis was one of those annulled by the court in its 2004 ruling, said at a San Francisco news conference with his lawyers and other plaintiffs. "Today is the happiest and most romantic day of our lives."

The celebration could turn out to be short-lived, however. The court's decision could be overturned in November, when Californians are likely to vote on a state constitutional amendment banning same-sex marriages. Conservative religious organizations have submitted more than 1.1 million signatures on initiative petitions, and officials are working to determine if at least 694,354 are valid.

If the measure qualifies for the ballot and voters approve it, it will supersede Thursday's ruling. The initiative does not say whether it would apply retroactively to annul marriages performed before November, an omission that would wind up before the courts.

Liberty Counsel, which represented the group Campaign for California Families before the court in arguing for the state law, denounced the ruling and said it would ask the justices to stay its effect until after the November election.

"The California Supreme Court has defied logic, undermined the will of the people and weakened our future," said Mathew Staver, Liberty Counsel's founder and chief attorney. "This decision will ignite California voters to amend their state Constitution to protect marriage and prevent judges from wrecking marriage."

Glen Lavy of Alliance Defense Fund, which represented other opponents of same-sex marriage, said, "The court's decision clearly demonstrates that marriage is not ultimately safe from tampering by activists and others in government until the voters have amended the Constitution."

Presidential politics

The ruling is certain to inject the issue into the presidential race, and could help Republicans by serving up a red-meat issue to rally conservative voters.

The California Supreme Court's decision echoed the Massachusetts Supreme Court's ruling legalizing gay marriage before the last presidential election in 2004. President Bush seized on the issue and pledged to support a federal constitutional ban on same-sex marriage, a move analysts say helped his re-election by energizing religious conservatives.

Republicans hope the California court's ruling could do the same for the party's presumptive nominee, Arizona Sen. John McCain, who has struggled to win over social conservatives.

"The California Supreme Court has just given Republicans an early Christmas gift," said Matt Barber, policy director for cultural issues for Concerned Women for America. "This will be at the top of the list of issues in the 2008 race, and it comes during a time when Republicans are in desperate need of something that will invigorate the base."

In 2004, 13 states passed ballot measures to ban same-sex marriage, including Ohio, where the measure boosted turnout among evangelical Christians and Catholics and might have helped Bush beat Democrat John Kerry. Now Florida, a key swing state, has a similar measure on the November ballot, and other states such as Arizona and Indiana could do the same.

The issue is not one Illinois Sen. Barack Obama or New York Sen. Hillary Clinton would prefer to see front and center -- polls show the public trusts the Democrats more on key issues such as health care and the economy.

"It certainly doesn't help them," said Nathaniel Persily, a professor of law at Columbia University, who has written extensively on the issue. "Right when everyone is thinking about a foreign policy disaster and the economy in ruins, you don't want them thinking about these other types of questions."

McCain angered some conservatives in 2004 by opposing a federal constitutional ban on same-sex marriage, which he called a state's-rights issue. Then, in 2006, he backed an unsuccessful effort in Arizona to pass a state constitutional ban. On Thursday, he released a statement that criticized the California court's ruling.

Obama's campaign released a carefully worded statement that said he "respects" the decision of the court without praising it.

"Barack Obama has always believed that same-sex couples should enjoy equal rights under the law, and he will continue to fight for civil unions as president," it read.