The California Supreme Court struck down the state's ban on same-sex marriage Thursday in a broadly worded decision that would invalidate virtually any law that discriminates on the basis of sexual orientation.

The 4-3 ruling declared that the state Constitution protects a fundamental "right to marry" that extends equally to same-sex couples. It tossed a highly emotional issue into the election year while opening the way for tens of thousands of gay people to wed in California, starting as early as mid-June.

The majority opinion, by Chief Justice Ronald M. George, declared that any law that discriminates on the basis of sexual orientation will from this point on be constitutionally suspect in California in the same way as laws that discriminate by race or gender, making the state's high court the first in the nation to adopt such a stringent standard.

The decision was a bold surprise from a moderately conservative, Republican-dominated court that legal scholars have long dubbed "cautious," and experts said it was likely to influence other courts around the country.

But the scope of the court's decision could be thrown into question by an initiative already heading toward the November ballot. The initiative would amend the state Constitution to prohibit same-sex unions.

The campaign over that measure began within minutes of the decision. The state's Catholic bishops and other opponents of same-sex marriage denounced the court's ruling. But Gov. Arnold Schwarzenegger, who previously has vetoed two bills in favor of gay marriage, issued a statement saying he "respects" the decision and "will not support an amendment to the constitution that would overturn" it.

The ruling was greeted with loud cheering and whooping when it was released at the high court's headquarters here Thursday morning. About 100 people lined up outside to purchase copies of the decision for $10 apiece. Some people bought 10 to 15 copies, calling it a historic document. One man said he planned to give them out as Christmas presents.

Gay groups planned celebrations up and down the state.

"I can finally say I will be able to marry John, the man that I love," said Stuart Gaffney, one of the plaintiffs in the case, referring to his partner of 21 years, John Lewis. "Today is the happiest and most romantic day of our lives."

Conservative and religious-affiliated groups denounced the decision and pledged to bring enough voters to the polls in November to overturn it. Mathew Staver, founder of Liberty Counsel, called the decision "outrageous" and "nonsense."

"No matter how you stretch California's Constitution, you cannot find anywhere in its text, its history or tradition that now, after so many years, it magically protects what most societies condemn," Staver said.

The decision came after high courts in New York, Washington and New Jersey refused to extend marriage rights to gay couples. Only Massachusetts' top court has ruled in favor of permitting gays to wed.

The court's ruling repeatedly invoked the words "respect and dignity" and framed the marriage question as one that deeply affected not just couples but also their children. California has more than 100,000 households headed by gay couples, about a quarter with children, according to 2000 census data.

"Our state now recognizes that an individual's capacity to establish a loving and long-term committed relationship with another person and responsibly to care for and raise children does not depend upon the individual's sexual orientation," George wrote for the majority. "An individual's sexual orientation -- like a person's race or gender -- does not constitute a legitimate basis upon which to deny or withhold legal rights."

Many gay Californians said that even the state's broadly worded domestic partnership law provided only a second-class substitute for marriage. The court agreed.

Giving a different name, such as "domestic partnership," to the "official family relationship" of same-sex couples imposes "appreciable harm" both on the couples and their children, the court said.

The distinction might cast "doubt on whether the official family relationship of same-sex couples enjoys dignity equal to that of opposite-sex couples," George wrote, joined by Justices Joyce L. Kennard, Kathryn Mickle Werdegar and Carlos R. Moreno. All but Moreno were appointed by Republican governors. George was appointed by Gov. Pete Wilson in 1991.

The ruling cited a 60-year-old precedent that struck down a ban on interracial marriage in California.

The three dissenting justices argued that it was up to the electorate or the Legislature to decide whether gays should be permitted to marry.

In 2000, 61% of California voters approved a ballot measure, Proposition 22, that said "only marriage between a man and a woman is valid and recognized in California."

Since then, the Legislature has passed one of the strongest domestic partnership laws in the country, giving registered same-sex couples most of the rights of married people.

"In my view, California should allow our gay and lesbian neighbors to call their unions marriage," Justice Carol A. Corrigan wrote in the first sentence of her dissent.

"But I, and this court, must acknowledge that a majority of Californians hold a different view and have explicitly said so by their vote. This court can overrule a vote of the people only if the Constitution compels us to do so. Here, the Constitution does not."

Justice Marvin R. Baxter, joined by Justice Ming W. Chin, said the ruling "creates the opportunity for further judicial extension of this perceived constitutional right into dangerous territory."

"Who can say that in 10, 15 or 20 years, an activist court might not rely on the majority's analysis to conclude, on the basis of a perceived evolution in community values, that the laws prohibiting polygamous and incestuous marriages were no longer constitutionally justified?" Baxter wrote.

The decision takes effect in 30 days. Gay couples would then be permitted to marry in California, even if they do not live in the state, gay rights lawyers said. Under federal law, however, other states would not have to recognize those marriages as valid. And same-sex couples would remain ineligible for certain federal benefits, including Social Security benefits for spouses and joint filing for income taxes.

Lawyers on both sides of the debate said they were uncertain how a victory for the proposed November initiative -- which both sides predict will qualify for the ballot -- would affect gay couples who marry during the next several months.

University of Santa Clara law professor Gerald Uelmen, who has closely followed the state high court for decades, said he was "blown away" and "very surprised" by the ruling.

"The court is exerting some leadership here, and I think it needs to be said that it is a new role for the court," Uelmen said.

"This has not been a court that has been willing to stick its neck out and lead the way on cutting-edge issues like this that involve such strong political feelings."

Uelmen said the court's vote probably reflected the fact that a growing number of Californians favor marriage for gay couples. He noted the case attracted a record number of friend-of-the-court briefs, most of them in favor of same-sex marriage.

Although critics of the ruling, including the dissenters, argued the court should have waited for the voters to decide the question of same-sex marriage, "the majority is not always supposed to have its way" in constitutional democracies, said University of Pennsylvania constitutional law professor Kermit Roosevelt, one of many legal scholars who weighed in on the case Thursday.

Roosevelt predicted more states would follow California's example and that the U.S. Supreme Court would eventually rule in favor of same-sex marriage.

"That decision will come at the end of a process that is now just beginning," Roosevelt said. He predicted it would follow the pattern of state courts that struck down laws banning interracial marriage decades ago.

The decision followed several recent rulings by the state high court recognizing the rights of same-sex parents, including those not biologically related to their children. The children in those families figured prominently in the court's reasoning in those cases.

The road to Thursday's ruling began with San Francisco's highly publicized same-sex weddings, which in 2004 helped spur a conservative backlash in an election year and a national dialogue over gay rights.

Several states later passed constitutional amendments banning gay marriage, and same-sex marriage became an issue in the race for president.

After a month of jubilant gay weddings here, the California Supreme Court intervened and ordered the city to stop issuing licenses to same-sex couples.

The state high court later invalidated the licenses, saying the city should have waited for a judicial ruling before acting.

The plan by San Francisco Mayor Gavin Newsom, City Atty. Dennis Herrera and gay rights lawyers to challenge state law by marrying same-sex couples was carefully drawn.

City officials chose the first couples to wed, hoping their long unions and sympathetic stories would put a face on same-sex marriage that courts would find difficult to reject. The city also decided to begin the weddings on a day when courts were closed to deprive opponents of quick legal intervention. One of the first couples to wed has since separated.

The long parade of weddings at City Hall -- across the street from the California Supreme Court -- provided a dramatic backdrop for the gay rights debate.

As the issue moved into the high court, Brad Sears, executive director of the Williams Institute at UCLA's law school, which examines sexual orientation and the law, said the state's broad domestic partner law had undercut the traditional argument that children were better off being raised by opposite-sex parents.

"Taking those issues off the table, which the domestic partners act did, might have made this an easier case for everyone," Sears said. Once the state recognized the right of gays to rear children, the fight for same-sex marriage was shaped as "the right to have a family" and the ruling became "about family being protected."

The court concluded that giving gays a separate institution -- domestic partnership -- "marked gays and lesbians as second-class citizens," Sears said.

The Massachusetts high court ruling that permitted gays there to marry did not give sexual orientation the same kind of constitutional protection that Thursday's decision did, nor was the Massachusetts ruling as explicit in stating that marriage licenses must be given to same-sex couples in the immediate future, legal analysts said.

Sears said recent polls show that Californians are divided over same-sex marriage. Forty-three percent of Californians supported gay marriage in a Field Poll taken a year ago.

He added that the issue was likely to affect the political debate even outside California.

"It is going to give some new teeth to an issue that was losing its potency in terms of being a wedge issue," Sears said.