Police officers try to separate supporters of the proposal to legalize same-sex marriage from demonstrators who are against the bill in Buenos Aires on Wednesday. ((Natacha Pisarenko/Associated Press))

Argentina legalized same-sex marriage Thursday, becoming the first country in Latin America to declare that gays and lesbians have all the legal rights, responsibilities and protections that marriage brings to heterosexual couples.

After a marathon debate in Argentina's senate, 33 lawmakers voted in favor, 27 against and three abstained in a vote that ended after 4 a.m. local time.

Since the lower house already approved it and President Cristina Fernandez is a strong supporter, it becomes law as soon as it is published in the official bulletin, which should happen within days.

The law is sure to bring a wave of marriages by gays and lesbians who have found Buenos Aires to be a welcoming place to live. But same-sex couples from other countries shouldn't rush their Argentine wedding plans, since only citizens and residents can wed in the country, and the necessary documents can take months to obtain.

While it makes some amendments to the civil code, many other aspects of family law will have to be changed.

Demonstrators supporting legalization of same-sex marriage wave a gay pride flag outside congress in Buenos Aires on Wednesday. ((Natacha Pisarenko/Associated Press))

The approval came despite a concerted campaign by the Roman Catholic Church and evangelical groups, which mustered 60,000 people to march on Congress and urged parents in churches and schools to work against passage. Cardinal Jorge Mario Bergoglio led the campaign, saying, "children need to have the right to be raised and educated by a father and a mother."

Nine gay couples had already married in Argentina after persuading judges that the constitutional mandate of equality supports their marriage rights, although their validity was later challenged by other judges. Congressional passage now removes that doubt.

As the debate stretched on overnight, large crowds held rival vigils through the frigid night outside the Congress building. When the final vote came, cheers and hugs broke out among the bill's supporters, with police keeping them separate from frustrated opponents who prayed and held rosaries.

"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 gay marriage inside the Senate chamber.

But 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," she said.

Same-sex civil unions have been legalized in Uruguay and some states in Mexico and Brazil. Colombia's Constitutional Court granted same-sex couples inheritance rights and allowed them to add their partners to health insurance plans. Mexico City went further, legalizing gay marriage and launching tourism campaigns to encourage foreigners to come and wed.

Argentina now becomes the first country in Latin America to legalize same-sex marriage nationwide, granting gays and lesbians all the rights and responsibilities that heterosexuals have. These include many more rights than civil unions, including adopting children and inheriting wealth.

Gay activists in neighboring Chile hope Argentina's milestone will improve chances for a gay marriage law currently in committee in their own congress.

"Argentina's political class has provided a lesson to the rest of Latin America," said Rolando Jimenez in Santiago. "We hope our own countries and political parties will learn that the human rights of sexual minorities are undeniable."

Activists in Paraguay plan to propose a similar law to the senate in October, said Martin Viveros of the group Somosgay. And in Uruguay, gays unsatisfied with the partial rights that come through civil unions are preparing legislation that would replace references to "man and woman" with "spouse" throughout the civil code.