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.