Argentina has become the first Latin American country to legalize same-sex marriage.
The move grants homosexual couples all the legal rights, responsibilities and protections that marriage gives heterosexual couples.
President Cristina Fernandez is a strong supporter and the new law is expected to bring a wave of marriages.
The approval came despite a concerted campaign by the Roman Catholic Church and evangelical groups, which drew 60,000 people to march on Congress and urged parents in churches and schools to work against passage.
Nine homosexual couples have already married in Argentina after persuading judges that Argentina's constitutional mandate of equality supports their marriage rights, but some of these marriages were later declared invalid.
The debate stretched on for nearly 16 hours.
"Marriage between a man and a woman has existed for centuries, and is essential for the perpetuation of the species," insisted Senator Juan Perez Alsina, who is usually a loyal supporter of the president but gave a passionate speech against legalizing same-sex marriage.
However, Senator Norma Morandini, another member of the president's party, compared the discrimination closeted gays face to the oppression imposed by Argentina's dictators decades ago. "What defines us is our humanity, and what runs against humanity is intolerance."
Same-sex civil unions have been legalized in Uruguay, Buenos Aires and some states in Mexico and Brazil. But Argentina now becomes the first country in Latin America to legalize same-sex marriage nationwide. Homosexual couples who marry will now get many more rights than civil unions, including adopting children and inheriting wealth.