San Francisco District Attorney General Kamala Harris has beaten her Republican rival to become California's next attorney general, the San Francisco Chronicle reported.

The narrow race dragged on for three weeks after the November 2 election.

Los Angeles District Attorney Steve Cooley declared victory on election night. But the race turned to Harris' favor as officials added in results from mail-in and provisional ballots. On Wednesday morning, Cooley conceded the race to Harris.

The candidates differed on whether to defend the state's gay marriage ban, Proposition 8, which Governor-elect Jerry Brown, as attorney general, declined to defend.

Cooley said he would defend the ban in court because the “proper role of an attorney general is to enforce and defend the will of the people as manifested through the initiative or legislative process.”

In a statement released on the day a federal judge ruled the law unconstitutional, Cooley said the ruling needed to be appealed.

“Today's decision by a federal judge overturning Proposition 8 should be appealed and tested at a higher level of our legal system,” Cooley said in a statement. “The California Supreme Court upheld Proposition 8 by a 6 to 1 vote and declared it to be constitutional. Likewise, if the voters had approved an initiative legalizing same-sex marriage and a federal judge had ruled against it, I would also support an appeal of that decision.”

Saying that Cooley either “does not understand the law or he is deliberately misleading people about its content,” Tobias Wolff, a University of Pennsylvania Law School Professor, disagreed with the Los Angeles County district attorney.

“In that first round of legal challenges to Proposition 8, the California Supreme Court did not rule on the constitutionality of Prop 8 under any provision of the U.S. Constitution. It was asked to decide only one question — whether state law permits a ballot initiative to be used in putting the fundamental rights of a protected minority up for popular vote,” Wolff told the Courage Campaign, a gay rights group that has been closely monitoring the case.

Harris, who enjoyed the endorsement of Equality California (EQCA), the state's largest gay rights advocate, promised to “never defend the anti-LGBT Proposition 8 in federal court.”

Harris will become the state's first female attorney general.