A statement from the federal Attorney General’s Office said the law “violates the principle of legality, because it strays from the constitutional principle of protecting the family”.
The office said it filed an appeal with the country’s Supreme Court asking it to void the law.
The law, approved in December, is due to come into effect in March. It also includes specific rights for gays to adopt and is the first such law in Latin America.
Mexico City Mayor Marcelo Ebrard on Thursday called the appeal a “grave mistake,” saying there is nothing in Mexico’s constitution that prohibits same-sex marriage or adoption by gay couples.
It is not the job of the federal Attorney General, Arturo Chavez, to decide the capital’s laws, Ebrard said.
Mexico City officials have said action from the Attorney General’s Office would not prevent the law coming into force.
The first gay marriages will be performed in early May while the Supreme Court hears the case, according to the city’s legal adviser, Leticia Bonifaz.