However, the conservative Nation Action Party of Mexico's president, Felipe Calderon, has vowed to challenge the gay marriage law in the courts.
Many people in Mexico and elsewhere in Latin America remain opposed to gay
marriage, and the dominant Roman Catholic Church has announced its opposition.
|Lawmakers backed the change in the definition of marriage by 39-20 votes [AFP]
"They have given Mexicans the most bitter Christmas," said Armando Martinez, the president of the College of Catholic Attorneys.
"They are permitting adoption [by gay couples] and in one stroke of the pen have erased the term 'mother' and 'father.'"
But Victor Romo, a city lawmaker and a member of the mayor's party, called the vote an historic day.
"For centuries unjust laws banned marriage between blacks and whites or Indians and Europeans," he said.
"Today all barriers have disappeared."
Monday's vote, which passed the city assembly 39-20, was cheered by gay rights activists who had gathered outside of the assembly building.
Under the bill, the definition of marriage in the city's civil code will be changed to "the free uniting of two people."
The change would allow same-sex couples to adopt children, apply for bank loans as a couple, inherit wealth and be included in the insurance policies of their spouse, rights they were denied under civil unions already allowed in the city.
Mexico City's left-led assembly has made several decisions unpopular elsewhere in this deeply Roman Catholic country, including legalising abortion in the first 12 weeks of pregnancy.
That decision sparked a backlash, with the majority of Mexico's other 32 states enacting legislation declaring life begins at conception.
Only seven countries allow gay marriages, including Canada, Spain, South Africa,
Sweden, Norway, the Netherlands and Belgium.
US states that permit same-sex marriage are Iowa, Massachusetts, Vermont, Connecticut and New Hampshire.