Argentina has become the first country in Latin America to legalise gay marriage after the Senate voted in favour.
The country's Chamber of Deputies had already approved the legislation.
The vote in the Senate, which backed the bill by just six votes, came after 14 hours of at times heated debate.
The law, which also allows same-sex couples to adopt, had met with fierce opposition from the Catholic Church and other religious groups.
The legislation, backed by President Cristina Fernandez's centre-left government, passed by 33 votes to 27 with three abstentions.
There were demonstrations for and against the bill outside Congress as senators debated Outside Congress, as the debate continued into the early hours of Thursday, supporters and opponents of the bill held rival demonstrations.
"Nearly every political and social figure has spoken out in favour of marriage equality," said Maria Rachid, president of the Argentine Federation of Lesbians, Gays, Bisexuals and Transsexuals.
"And we hope that the Senate reflects this and that Argentina, from today forward, is a more just country for all families," she told the Associated Press.
Continue reading the main story
“
Start Quote
All that my boyfriend and I want is to adopt a child and be accepted by society”
End Quote
Lionel, Cordoba, Argentina
Your comments Q&A: Argentina gay marriage law Ines Frank, from a group called Argentine Families Argentina, said opposition was not discrimination "because the essence of a family is between two people of opposite sexes".
There have been several gay marriages recently in Argentina, some of which were annulled by the Supreme Court, creating a legal controversy.
Civil unions between people of the same sex are legal in Buenos Aires and in some other provinces but there was no law to regulate it on a country-wide level.
Argentina's capital is widely considered to be among the most gay-friendly cities in Latin America. It was the first Latin American city to legalise same-sex unions.
Same-sex civil unions are also legal in Uruguay and some states in Brazil and Mexico, while gay marriage is legal in Mexico City.
It's about damned time! The halfway point is slowly approaching. Now here's hoping we can work it out in those parts of the USA that are being pig-headed about it.
Praying is another way of doing nothing helpful
"Congratulations, you get a cookie. You almost got a fundamental English word correct." Pick
"Outlaw star has spaceships that punch eachother" Joviwan Read "Tales From The Crossroads"! Read "One Wrong Turn"!
Mexico City has offered a free honeymoon to the first gay couple to marry in Argentina under a new law.
The couple would have all expenses paid in the Mexican capital and in the beach resort of Cancun, the city's tourism secretary, Alejandro Rojas, said.
On Thursday, Argentina became the first Latin American country to legalise same-sex marriage.
Mexico City also allows gay couples to wed.
The city government would pay the air fares for the newly-wed couple and is seeking sponsorship from hotels and restaurants to finance the rest of the honeymoon, Mr Rojas said.
The offer was "a recognition of tolerance, but first and foremost a way to promote gay tourism in Mexico".
The left-leaning Mexico City government legalised same-sex marriage in 2009 and also allows gay couples to adopt children.
The BBC correspondent in Mexico, Julian Miglierini, says some Mexicans consider the invitation to be simply a publicity stunt.
But he says the offer by the capital's authorities also shows how the new law in Argentina could galvanise the demand for gay rights across Latin America.
Ph34r teh eyebrow!!11!Writers GuildSluggitePawn of ChaosWYGIWYGAINGW so now i have to put ACPATHNTDWATGODW in my sigEBC-Honorary Geordie Hammerman! Hammer!