California's Supreme Court upheld a ban on gay marriage but said some 18,000 same-sex weddings carried out before the ban took effect would remain valid.
Gay and lesbian activists had sought to overturn the result of a November referendum known as Proposition 8 that redefined marriage in California as unions between men and women only.
But California Supreme Court justices said in a six to one majority opinion that the referendum -- which passed by a margin of 52.5 to 47.5 percent -- was legal and could not be quashed.
The decision was a bitter blow for same-sex marriage advocates, who held protests outside the court and across California on Tuesday.
"There's no way to sugarcoat it; this is a very sad day for our community," said Shannon Minter, legal director for the National Center for Lesbian Rights and an attorney who had argued in court for the referendum to be overturned.
Minter said activists would now seek to place the issue back before voters in a further referendum.
"Today's decision is a terrible blow ... But our path ahead is now clear. We will go back to the ballot box and we will win," Minter said.
Around 175 protesters were arrested in San Francisco after blocking a street near the court house in a peaceful demonstration. Chants of "Shame on you, shame on you" rang out after the ruling as protestors voiced dismay.