The change makes Mexico City the first place in deeply Catholic Latin America to legalize gay marriage. It also puts it a step ahead of New York where the senate voted down a same-sex marriage bill on Dec. 2.
The measure also extends to married gays the right to adopt. Marcelo Ebrard, the city's left-wing mayor, is expected to sign the measure into law.
The measure is certain to spark a backlash. The National Action Party of President Felipe Calderon has promised to mount a legal challenge to the measure. The Roman Catholic church also can be counted on to mobilize opposition.
Mexico City has a tradition of radicalism on social issues that is often at odds with the traditional conservatism of much of the rest of the country. It passed a law permitting abortions during the first 12 weeks of pregnancy, pushing most of Mexico's states to pass legislation defining conception as the beginning of human life.