In 2010, Cooley won the Republican nomination for California Attorney General against John C. Eastman and Tom Harman in the June 8 primary election. During the general election campaign, Cooley said he would defend Proposition 8, a 2008 ballot measure that banned same-sex marriages in California but was then being appealed in the federal courts. Cooley lost to the Democratic nominee, San Francisco District Attorney Kamala Harris, in the November 2 general election, a close race whose results were not finalized until November 24, 2010.