In a 4-3 ruling, the justices said that domestic partnerships are not a good enough substitute for marriage.
"Under these circumstances, we cannot find that retention of the traditional definition of marriage constitutes a compelling state interest," the court said in a majority decision, written by Chief Justice Ron George.
"Accordingly, we conclude that to the extent the current California statutory provisions limit marriage to opposite-sex couples, these statutes are unconstitutional."
In February 2004, the mayor of San Francisco started issuing gay marriage licenses in defiance of state marriage laws, allowing nearly 4,000 couples to wed in the span of a month before courts ruled that they held no legal validity. The city of San Francisco, 23 of the couples and a gay rights group sued and the case made it to the state's Supreme Court.
A 2000 ballot measure, know as Proposition 22, was ratified by a 23-point margin to define marriage as the union of a man and a woman Civil union legislation passed in 2005 gave gay couples many of the same legal privileges as married couples, including the right to divorce and sue for child support.
Six of the California Supreme Court's judges were appointed by Republican governors and the body is considered politically moderate.
Other states have tackled similar cases, with Massachusetts, New Jersey and Vermont ruling against limiting the benefits of marriage to a man and a woman.
Massachusetts is the only U.S. state to allow gay marriage. Its highest court ruled in 2003 that a ban on gay marriage was unconstitutional, paving the way for America's first same-sex marriages the following year.
Voters could see the issue emerge again if a group of conservative religious organizations obtain enough signatures to put an initiative on the November ballot that would amend the state Constitution to outlaw same-sex marriages.