(CNN) -- Mexico City, one of Latin America's largest metropolises, on Monday legalized same-sex marriage and adoption by same-sex couples.
By a vote of 39 to 20, the city's legislative assembly approved revisions to the civil code to permit same-sex marriages. Five legislators abstained.
In a separate motion, the assembly voted 31 to 24 in favor of legalizing adoption by same-sex couples, with nine abstentions.
The revision will change the definition of marriage to a union between two people, instead of the current version, which specifies a union between a man and a woman.
Civil groups in favor and opposed to the vote had gathered since early in the morning outside the legislative building.
In 2007, the legislators approved same-sex civil unions.
Mexico City is the second major Latin American city to legalize same-sex marriage.
In November, a Buenos Aires, Argentina, court ruled that two articles in the city's civil code that say only a man and woman can be married are illegal, paving the way for gay marriages. The mayor of Buenos Aires, Mauricio Macri, announced that his administration would not appeal the decision, clearing the way for the gay couple who took the issue to court.
The first same-sex marriages to be held under the new law, however, was delayed after another court filed a contradictory order.
CNN en Español's Rey Rodriguez contributed to this report.