Following a long and tense debate among lawmakers, Argentina has joined Canada as one of a select few nations to legalize marriages between same-sex couples.

The ruling early Thursday makes Argentina the first country in Latin America to grant gays and lesbians all the legal rights, responsibilities and protections that marriage brings heterosexual couples.

Following more than 14 hours of heated debate during which thousands of Argentines protested outside the Congress, the vote in the upper house came down to 33-27 for the proposal, with three abstentions.

Since the lower house already approved the bill in May and President Cristina Fernandez is a strong supporter of gay marriage on human rights grounds, it's expected she'll sign the bill into law after her return from a state visit to China.

Opinion polls show a majority of Argentines support gay marriage, and many senators publicly states that they supported it, too.

"I believe this has advanced equal rights," Sen. Eugenio Artaza told reporters after the debate.

Sen. Juan Perez Alsina, who is usually a loyal supporter of the president, disagreed.

"Marriage between a man and a woman has existed for centuries, and is essential for the perpetuation of the species," he insisted.

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."

The approval came despite a concerted campaign by the Roman Catholic Church and evangelical groups, which drew 60,000 people to march on Congress.

Opponents, from children to elderly nuns, braved near-freezing temperatures to protest outside the Congress since Tuesday, snarling traffic in Buenos Aires.

The Senate's decision is sure to bring a wave of marriages by gays and lesbians who have increasingly found Buenos Aires to be more accepting than many other places in the region.

Same-sex civil unions -- not marriages -- had already been legal in Buenos Aires, as well as Uruguay and some states in Mexico and Brazil.

Mexico City has legalized gay marriage. And Colombia's constitutional court granted same-sex couples inheritance rights and allowed them to add their partners to health insurance plans.

With Thursday's decision, married gay couples can now adopt children and inherit wealth, which they couldn't do under same-sex unions.

Argentina is the first country in South America to legalize same-sex marriage nationwide.

Nine gay 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.