After a marathon debate that lasted more than 16 hours, the vote was 33 in favor, 27 against and 3 abstentions in Argentina's Senate. Since the lower house already approved the bill and President Cristina Fernandez is a strong supporter, it now becomes the law of the land.
The bill passed despite a concerted campaign by the Roman Catholic Church and evangelical groups, which drew 60,000 people to a march on Congress earlier this week.
As debate dragged into the wee hours, supporters and opponents held rival vigils throughout the frigid night outside the Congress building in Buenos Aires.
"Marriage between a man and a woman has existed for centuries, and is essential for the perpetuation of the species," insisted Sen. Juan Perez Alsina, usually a loyal supporter of the president who gave a passionate speech against gay marriage.
But Sen. Norma Morandini, another member of the president's party, compared the discrimination that 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," she said.
Same-sex civil unions have been legalized in Uruguay, Buenos Aires and some states in Mexico and Brazil. Mexico City has legalized gay marriage. Colombia's Constitutional Court granted same-sex couples inheritance rights and allowed them to add their partners to health insurance plans.
But Argentina now becomes the first country in Latin America to legalize same-sex marriage nationwide, granting gays and lesbians all the same rights and responsibilities that heterosexuals have. These include many more rights than civil unions, including adopting children and inheriting wealth. The proposed law broadly declares that "marriage provides for the same requisites and effects independent of whether the contracting parties are of the same or different sex."
"Nearly every political and social figure has spoken out in favor of marriage equality for everyone," said Maria Rachid, president of the Argentine Federation of Lesbians, Gays, Bisexuals and Transsexuals. "Argentina, from today forward, is a more just country for all families."
Nine gay couples have already married in Argentina after petitioning judges, but other judges challenged some of the marriages as invalid.
Among the opponents were teacher Eduardo Morales, who said he believes the legislation was concocted by Buenos Aires residents who are out step with the views of the country.
"They want to convert this city into the gay capital of the world," said Morales of San Luis province.
Ines Franck, director of the group Familias Argentinas, said the legislation cuts against centuries of tradition.
Opposing the measure "is not discrimination, because the essence of a family is between two people of opposite sexes," he said. "Any variation goes against the law, and against nature."
The president, currently on a state visit to China, spoke out from there against the Argentine Catholic Church's campaign.
"It's very worrisome to hear words like 'God's war' or 'the devil's project,' things that recall the times of the Inquisition," she said.
Some opposition leaders have accused the couple of promoting the initiative to gain votes in next year's presidential elections, when Fernandez's husband, former President Nestor Kirchner, is expected to run again.
The vote came after Sen. Daniel Filmus urged fellow lawmakers to show the world how much the society has matured.
"Argentina is providing a demonstration of its maturity. The society has grown up. We aren't the same as we were before," he said.