A Brazilian state judge has approved what the court said is the nation's first gay marriage.
Sao Paulo state Judge Fernando Henrique Pinto ruled two men could convert their civil union into a full marriage.
Brazil's Supreme Court cleared the way in May for the recognition of same-sex civil unions, but stopped short of approving gay marriages.
A court statement said Mr Pinto made the decision based on the top court's ruling on civil unions and on Brazil's constitution, which outlines how a civil union can be converted into a legal marriage.
Benjamin Polastri, a spokesman with the Sao Paulo state Attorney General's Office, said it was not immediately clear if the ruling set a strong national precedent. Mr Polastri also said the just-approved gay marriage was the first for South America's biggest nation.
Jose Luiz Bednarski, a lawyer for the Sao Paulo state attorney general, said in an opinion presented to Mr Pinto that the marriage was legal. "The federal constitution establishes as a fundamental objective of the Federal Republic of Brazil to promote the good of everyone without bias of gender or any other form of discrimination," Mr Bednarski wrote. "This certainly includes the choice or sexual orientation of a person."
In the Brazilian legal system, judges often seek the opinion of a state or federal attorney general about a case.
While the court released only the initials of the couple that was married, the Globo television network's G1 website identified the men as Sergio Kauffman Sousa and Luiz Andre Moresi. They asked a state court in the city of Jacarei, 53 miles north east of Sao Paulo, to approve their marriage.
"It's an immense joy. I'm still trying to comprehend this historic moment," Mr Moresi told G1. "We've fought for so many years and now that it has happened we are in ecstasy. I dedicate this victory to all the activists."
Luiz Mott, founder of Grupo Gay da Bahia, the oldest gay rights organisation in Brazil, called the marriage a huge step for LGBT rights in the country. "Now any couple can ask for the same thing. It's a great advance," he said.