Uruguay's Senate has voted to legalise same-sex marriage by approving a single law governing matrimony for heterosexuals and homosexuals.
Tuesday's 23-8 vote comes after a lower-house approval in December. It will now return to the lower chamber of Congress for amendments.
If the bill is approved, Uruguay will become the second nation in Latin America, after Argentina, and the twelfth in the world to legalise gay marriage.
"It goes beyond homosexuality, it's about a law where everyone shares the same rights and obligations,'' said Federico Grana, a legislator in the ruling Frente Amplio coalition and a member of the Black Sheep Collective, a gay rights group that presented the bill's first draft.
The bill lets couples, gay or straight, decide whose surname goes first when they name their children.
"This is an issue of liberty, of people's choice and justice,'' said Senator Rafael Michelini.
"Liberty because the state should not meddle in who you should marry; of justice because if you marry abroad with someone of the same sex and later return to Uruguay, your marriage should be recognised.''
The bill also clarifies rules for adoption and in-vitro fertilisation (IVF), and eliminates the words "husband and wife" in marriage contracts, referring instead to the gender-neutral "contracting parties".
The Roman Catholic Church opposes the proposal, but the Church has little political influence in secular Uruguay, which became the first Latin American country to legalise abortion last year.
President Jose Mujica has been pushing for liberal-leaning proposals in his mandate and says he plans to sign the marriage bill into law.
US-based Human Rights Watch welcomed the Senate vote, urging the lower house to pass the bill swiftly.
"Uruguayan senators made the right decision by allowing same-sex couples to marry," said the group's Boris Dittrich.
"Final approval will enable gays and lesbians in Uruguay to marry the person they love and will strengthen the fundamental rights of everyone in Uruguay to equality and non-discrimination."
The bill also includes a measure to raise the minimum age for marriage to 16 for everyone, instead of the present age 12 for girls and 14 for boys.