The secretary of state said that with 95 percent of precincts reporting the proposal to limit marriage to members of the opposite sex had been approved by 52.1 percent of voters, compared with 47.9 percent who voted against.
The referendum called for the California constitution to be amended by adding the phrase that: "Only marriage between a man and a woman is valid or recognized in California."
Known as "Proposition 8," the proposal was trumpeted by conservative groups as the people's way of overturning the state Supreme Court's ruling in May that legalized gay marriage.
The court's ruling had overturned an earlier plebiscite in 2000 when 61 percent of voters agreed marriage should be defined as being between a man and a woman.
The result leaves thousands of gay couples in a legal limbo after they rushed to get married in California since June.
They include some celebrity marriages such as comdienne Ellen DeGeneres who wed her her long-time girlfriend Portia de Rossi in August.
Hollywood stars including Brad Pitt and Steven Spielberg as well as multinational companies such as Apple had flocked to the "No" camp against the ban, with donations of up to 100,000 dollars.
But supporters unleashed a flood of hard-hitting ads especially targeting the Hispanic community and its traditional Christian and family values.