(CNN) -- Mexico's Supreme Court on Monday ruled that a law allowing for adoption by gay couples in Mexico City is legal.
The court had already upheld the constitutionality of the capital's gay marriage law.
In a 9-2 vote, the high court ruled that the part of the law that legalized adoptions by same-sex couples was also constitutional.
The law only applies to Mexico City, but the judges have said that the marriages in Mexico City should be recognized across the country, even if legislatures in the rest of the country don't follow suit. Likewise, the validity of Mexico City adoptions by gay couples should be recognized throughout the country, the justices said.
The justices in favor of the bill spoke said that since gay marriage was already upheld, so should all of the rights that come along with it, the state-run Notimex news agency reported.
The lawsuit against the gay marriage law was presented by the federal attorney general's office, which challenged the legality of the measure.