After an intense campaign that cost more than $75 million, California’s voters have approved a constitutional ban on same-sex marriage, dealing a huge blow to the gay rights movement and setting the stage for another round of court battles over the volatile issue.

Opponents this morning refused to concede the outcome, saying there may be as many as four million uncounted ballots.

“We are not in a position to call this. Really this is just fundamental,” said Kate Kendell, executive director for the National Center for Lesbian Rights. “We really need to wait until there is something authoritative issued by the Secretary of State’s office. Until that happens, we do not feel it is appropriate for us to make our own call, absent the counting of millions of ballots.”

While the Yes on 8 campaign claimed victory just before midnight, the numbers continued to play out in their favor this morning. Still, advocates of same-sex marriage had clung to hopes that a surge of support from uncounted votes could still overcome the ban.

But this morning, with 95 percent of precincts reporting, the measure passed with 52 percent in favor, and 47.9 percent opposed. There are an untold number of absentee and provisional ballots left to be counted, according to the Associated Press, but it will be hard to overcome the 5 percent margin. The San Francisco City Attorney’s office says he plans to file the legal challenge in the California Supreme Court to challenge the validity of the measure. Also, the first lesbian couple to be married in Los Angeles County after the Supreme Court threw out the gay marriage ban plans to announce a lawsuit arguing that the proposition is unconstitutional.

“I think the story is that a strong majority of Californians support traditional marriage and they want to see it protected,” said Frank Schubert, manager of the Yes on 8 campaign. “I think the story is we ran a far better campaign than the other side. I think we had 100,000 people that gave of their resources and their time.”

The measure trims the number of states in which gays and lesbians can legally marry from three to two. But in striking the most populous and culturally influential state from that list, social conservatives and religious leaders have scored a much broader victory, likely limiting for years the hopes of gay rights leaders to allow same-sex couples to marry across the United States.

For same-sex marriage supporters, it was a bitter loss, after major polls had consistently shown the measure losing through the fall.

In San Jose, Ronni Pahl, a member of one of the first two same-sex couples married in Santa Clara County, watched the returns with her wife, Hannah, and son Isaiah with a potent mix of emotion.

“It’s bittersweet right now because we just watched the first African-American president elected. We were watching it with our African-American son, there were tears coming out of our eyes, and we went to look at what’s happening at 8,” Pahl said. “We’re speechless right now.”

In Santa Clara County, Proposition 8 was soundly defeated, losing by a 10 percent margin. The measure also trailed in Alameda, San Mateo and Santa Cruz counties, as well as in San Francisco.

But as election evening wore on, that opposition was overwhelmed by more conservative areas of the state, particularly in the inland counties. The same-sex marriage ban had attracted more than 60 percent of the vote in Riverside County, and two-thirds of the vote in San Joaquin County, with more than half of precincts reporting in those counties.

And despite the decisive win of Democratic nominee Barack Obama, in California and the rest of the country, polls were wrong in another way: They had predicted that the tide of Obama voters would block Proposition 8 from passing. But even in Santa Clara County, Obama captured a much higher share of the vote than the proportion who voted against Proposition 8.

Schubert said the Yes on 8 campaign never trusted the polls.

“We’ve always felt that if we were tied going into Election Day, or a few points behind, we were going to win,” he said. The decision “is something that I think will reverberate across the nation and around the world.”

A constitutional bans on same-sex marriage was also approved in Florida — a state also won by Obama — and in Arizona. But for the gay rights leaders, this loss in California was more painful, because it marked the first time that voters rejected same-sex marriage in a state where it was already legal.

While the new constitutional ban goes into effect immediately, it’s less clear what the effect will be on same-sex couples who married from June 16 through Tuesday. While Attorney General Jerry Brown has said he does not believe Proposition 8 is retroactive, that issue is likely to wind up back in the courts, as well as an anticipated challenge to whether it is constitutional for California to revive its ban on same-sex marriage.

The race began to tighten when the Yes on 8 campaign began running ads that suggested that churches could lose their tax-exempt status if clergy refused to do gay weddings and that second-graders would be taught about gay marriage.

The figurehead of those ads: San Francisco Mayor Gavin Newsom, proclaiming in a speech that gay marriage was now legal in California “whether you like it or not.”

Yes on 8 supporters were feeling confident Tuesday night, even as the polls began to close.

“The momentum has really been with us,” said Chip White, the press secretary for the Yes on 8 campaign. “The trend has been in our direction ever since we went with that Gavin Newsom ad on Sept. 29.”

David McCuan, a political-science professor at Sonoma State University, said the move to victory for the Yes on 8 campaign might have begun here, when a campaign pushing for passage of an initiative began to behave like a classic “No” campaign — by injecting doubt about the effect of a proposed “change” into the minds of voters.

Because gay marriage was so new in California, it allowed Yes on 8 campaign manager Frank Schubert to operate as if what was technically the status quo was actually a proposed change, and trying to inject doubt into the minds of voters about that “change.”

Schubert “essentially ran a No side campaign on the Yes side of this ballot measure and that has made it more sophisticated and less faith-based message,” McCuan said.

Given Obama’s victory, “it’s a stunning, stinging defeat,” McCuan said. “This is a Democratic blue wave and standing out in one of the bluest of the blue states is this huge red result.”

The Associated Press contributed to this report. Contact Mike Swift at mswift@mercurynews.com or at (408) 271-3648.