Congress in Uruguay has voted overwhelmingly to legalise gay marriage, becoming the second country in Latin America to do so, after Argentina.
The bill was approved by more than two-thirds of the lower chamber, despite opposition from the Catholic Church.
The proposal has already been backed by the upper house. It is expected to be signed into law within two weeks.
President Jose Mujica has been championing the bill.
Despite opposition from the Roman Catholic Church in Uruguay, 71 out of 92 deputies have voted in favour of the measure.
"Freedom, freedom," shouted activists who were attending the session in the Congress building in Montevideo as the result was announced.
"Same-sex couples have always existed," said Mr Mujica, a former left-wing guerrilla, in a television interview with Russia Today earlier this year.
Age of consent
The Marriage Equality Law was approved by the Senate last week by 23 votes to 8.
It allows same-sex couples to choose the order of the surnames of the children they adopt.
And it also increases the age of consent for sexual relations to 16, from the current 12 for women and 14 for men.
In recent years, Uruguay has moved to allow same-sex civil unions, adoption by gay couples, and to allow gay members of the armed forces.
Uruguay's neighbour Argentina legalised gay marriage in 2010. Same-sex marriages have been legal in Mexico City since 2009.
In May, Brazil's Supreme Court voted overwhelmingly in favour of allowing same-sex couples the same legal rights as married heterosexuals.