The measure to amend the state’s Civil Code passed with 23 votes in favor, 12 against and two abstentions, setting off cheers of “Yes, we can!” from supporters of the change.
The session took place as groups both for and against the measure chanted and shouted from the balcony, and legislators eventually moved to another room to finish their debate and vote.
The president of the Supreme Court of Justice of the Nation, Arturo Zaldívar, welcomed the vote. “The whole country shines with a huge rainbow. Live the dignity and rights of all people. Love is love,” he said on Twitter.
A day earlier, lawmakers in the southern state of Guerrero approved similar legislation allowing same-sex marriages.
In 2015, the Supreme Court declared state laws preventing same-sex marriage unconstitutional, but some states took several years to adopt laws conforming with the ruling.