Mexico's Supreme Court has upheld Mexico City's gay marriage law, the AP reported.

Justices ruled 8-2 Thursday that the law approved by lawmakers in December is constitutional.

The law went into effect in March. It gives gay and lesbian couples all the rights and responsibilities of marriage, including the right to adopt children. Previously, the city government recognized gay couples with civil unions, but gay adoption was banned.

The court must still rule on the constitutionality of the law's adoption provision, which will be considered on Monday.

Calling the law detrimental to children, the federal Attorney General's Office had challenged the law.

The federal government is controlled by the conservative PAN Party. Mexico City lawmakers approved the law over the objections of local PAN leaders and the Roman Catholic Church.

Mexico's Roman Catholic archbishop, Cardinal Noberto Rivera Carrera, called the law “immoral” and “reprehensible.”

The ruling comes a day after a federal judge in California struck down the state's gay marriage ban.

Mexico City was the first autonomous government to legalize gay marriage in Latin America and several countries in the region have followed its lead. Argentina approved a gay marriage law last month. Chile, the last country on the continent to allow divorce, Uruguay, and Paraguay say they'll consider a gay marriage law. Peru will debate a bill that recognizes gay and lesbian couples with civil unions.

Officials in Mexico City announced earlier this week that 320 gay couples have married since the law's enactment.