The California legislature became the first legislative body in the US to approve same-sex marriages, as gay-rights advocates overcame two earlier defeats in the assembly.
The 41-35 vote sends the bill to Governor Arnold Schwarzenegger, who had no comment on the bill when it cleared the state senate last week. His office did not immediately respond late on Tuesday to a call seeking comment.
The bill's supporters compared the legislation to earlier civil-rights campaigns, including efforts to eradicate slavery and give women the right to vote.
"Do what we know is in our hearts," said the bill's sponsor, San Francisco Democrat Mark Leno. "Make sure all California families will have the same protection under the law."
Leno's bill had failed in the assembly by four votes in June, but he was confident he could get it through on a second try after the senate approved a same-sex marriage bill last week.
Democratic Assemblyman Paul Koretz called bans on gay marriage "the last frontier of bigotry and discrimination, and it's time we put an end to it."
Assemblyman Tom Umberg, a Democrat who abstained when another gay-marriage bill fell four votes short in June, said he was concerned about what his three children would think of him if he didn't join those "who sought to take a leadership role in terms of tolerance, equality and fairness."
But opponents repeatedly cited the public's vote five years ago to approve Proposition 22, an initiative put on the ballot by gay-marriage opponents to keep California from recognizing same-sex marriages performed in other states or countries.
"History will record that you betrayed your constituents and their moral and ethical values," Republican Assemblyman Jay La Suer said.
The vote was hailed by gay and lesbian advocates, including Geoff Kors, executive director of Equality California, a backer of the bill.
"As the debate today shows, love conquers fear, principle conquers politics and equality conquers injustice, and the governor can now secure his legacy as a true leader by signing this bill," Kors said.
California already gives same-sex couples many of the rights and duties of marriage if they register with the state as domestic partners.
Regardless of what action Schwarzenegger takes, California's debate over gay marriage will continue on several fronts.
A state appeals court is considering challenges to a lower court ruling that overturned California laws banning recognition of gay marriages.
And opponents of same-sex marriage are trying to qualify initiatives for next year's ballot that would amend the state Constitution to ban same-sex marriages.