Gays in Mexico's capital today can marry and adopt children, broad rights that go beyond anything offered in much of the world and enshrined now by a remarkable series of rulings by the nation's Supreme Court.
But reaching this point has left casualties along the way.
For President Felipe Calderon and his conservative National Action Party, the decision to challenge Mexico City's same-sex marriage law backfired. Not only did the 11-member court reaffirm the law, but the wording of its rulings could make it more difficult for states to mount challenges.
And the debate ignited an ugly spat with the Roman Catholic Church, with one of the country's top prelates accusing the court of being on the take.
As gay marriage languishes in California, the state's law in limbo, the Mexican Supreme Court voted overwhelmingly this month to uphold the capital's same-sex marriage statute as constitutional; to require such unions to be recognized across the nation; and to permit gay and lesbian couples to adopt children.
The court hewed to Mexico's strict separation of church and state and said the constitution did not indicate that marriage had to be defined as the union of a man and woman. To deny gay couples the right to adopt, the court said, would amount to discrimination.
"There is nothing that indicates that homosexual couples are less apt parents than heterosexual ones," Justice Arturo Zaldivar said in televised proceedings this week.
The adoption provision was upheld 9 to 2 in a vote Monday, as proponents erupted in cheers of "Marriage and adoption! For all the nation!"
The law was first approved by Mexico City's left-dominated government in December — the most far-reaching such legislation in Latin America at the time — and the first marriages took place in March. Mexico City is a federal district like Washington, D.C., and acts as a state.
Immediately Calderon instructed his attorney general to take the law to court, arguing that it posed a threat to traditional families and the procreation of children. Yet even justices appointed by Calderon's PAN party voted to overrule the president.
"This has been an important demonstration of the judicial and political independence of the court," said John Mill Ackerman, a legal expert at the National Autonomous University of Mexico and editor of the Mexican Law Review.
The justices' supplemental ruling that all of Mexico's 31 states must recognize same-sex marriages performed in Mexico City may serve as a preemptive strike to efforts by local authorities to legislate against such unions, Ackerman said. When Mexico City legalized abortion in 2007, a backlash followed in which 17 states introduced measures aimed at "protecting" fetuses and making abortion impossible.
In Mexico, the government recognizes civil weddings, while religious ceremonies are optional.
The fiercest resistance to same-sex marriage has come from the influential Catholic Church.
Cardinal Juan Sandoval Iniguez, archbishop of Guadalajara and one of the most senior prelates in the nation, in recent days made especially harsh comments widely seen here as offensive. His statement set off a firestorm in a country where, by law, the church is not supposed to get involved in politics.
Calling same-sex unions an "aberration," he said, "Would you want to be adopted by a pair of faggots or lesbians?"
He went on to accuse Mexico City Mayor Marcelo Ebrard, of the leftist Democratic Revolution Party, of bribing the justices to force them to go along with gay marriage.
"I don't think the judges would arrive at such absurd conclusions, against the sentiment of the Mexican public, without there being very big motives," Sandoval said, "and the very big motive may be the money that they are given."
The comments stunned many in Mexico. Ebrard demanded a retraction and threatened to sue. The court, which had included dissenters in the votes on same-sex issues, was unanimous in censuring the cardinal.
But Sandoval did not back down. He received the support of the archdiocese of Mexico City and, when asked whether he had proof of his accusations, added, "Check their bank accounts."
Such comments are virtually unheard of here, and some analysts suggested church authorities may feel emboldened by their closeness with the ruling PAN. Yet Sandoval's reaction was too much even for some members of the party, who said that ultimately the court's decision must be respected.
"There was a tone and content of intolerance [in Sandoval's comments] that are totally incongruous with what should be the attitude of the Catholic Church," television commentator Gabriel Guerra said. Besides, he added, "if Ebrard were really able to co-opt 11 members of the Supreme Court, he'd deserve a prize for efficiency."
It did not seem likely there would be a rush on adoptions by gay couples. Single men and women were already allowed to adopt, so gays in theory could have gotten around any proscriptions before now. And only about 320 same-sex couples have tied the knot in Mexico City since the law went into effect in March.