Argentina's senators on Thursday voted against legalizing abortion in the homeland of Pope Francis, dashing the hopes of women's rights groups after the bill was approved by the legislature's lower house months earlier.

The vote, with 38 against, 31 in favor and two abstentions, capped a marathon session that began the day before and stretched into the early hours of Thursday.

Fireworks and shouts of joy erupted among anti-abortion activists camped outside Congress, while pro-choice campaigners, many decked in the green scarves that had come to symbolize their movement, were downcast.

Some burnt garbage and wooden pallets and threw stones at riot police, who attempted to disperse them with tear gas and water cannon.

The vote followed a referendum in Ireland, another traditionally Catholic country, in May that paved the way to legislate for the termination of fetuses. It also came after months of heated campaigns on the polarizing issue.

The bill was passed by Congress's lower house in June by the narrowest of margins, but was widely expected to fall short of the votes needed to pass in the Senate.

Lawmakers must now wait a year to resubmit the legislation.

Not giving up 

Miguel Angel Pichetto, a Peronist opposition leader in the Senate, said pro-abortion campaigners would not be giving up.

"The future does not belong to the "No" campaigners. Sooner rather than later, women will have the decision they need, sooner rather than later we will win this debate," he said in his closing speech.

His sentiments were shared by 21-year-old Camila Sforza, who said she remained hopeful despite the setback.

"This is just the beginning -- our movement will continue till we get the right to abortion," she said.

The move was also condemned by Amnesty International, which said Argentina had squandered an historic opportunity.

“The Argentine lawmakers chose today to turn their backs on hundreds of thousands of women and girls who have been fighting for their sexual and reproductive rights," said Mariela Belski, the group's executive director for Argentina.

She added that the Senate had "therefore decided to agree on a system which forces women, girls and others who can become pregnant to undergo clandestine and unsafe abortions."

But among anti-abortion activists, the mood was one of jubilation.

"We are happy because it is a celebration of democracy, the triumph of both lives," said Ayelen Caffarena, echoing the campaign's slogan, "save both lives", a reference to the mother as well as the unborn child.

Earlier in the day, scores of buses had brought people from around the country into Buenos Aires for the dueling rallies outside Congress.

A partition was set up to keep the green-decked pro-abortion contingent separated from the anti-abortion activists who donned baby blue.

Currently, abortion is allowed in Argentina in only three cases, similar to most of Latin America: rape, a threat to the mother's life or if the fetus is disabled.

The bill had sought to legalize abortion during the first 14 weeks of pregnancy and would have seen Argentina join Uruguay and Cuba as the only countries in Latin America to fully decriminalize abortion.

It is also legal in Mexico City. Only in the Central American trio of El Salvador, Honduras and Nicaragua does it remain totally banned.

Referendum possibility

The prospect of legalization had energized women's groups and still retains a huge support from citizens.

Rallies took place around the world in front of Argentine diplomatic missions, mainly in support of the bill.

Various charities estimate that 500,000 illegal, secret abortions are carried out every year in Argentina, resulting in around 100 deaths.

Opponents of abortion meanwhile held their own demonstrations.

Priests and nuns were joined by rabbis, imams and members of other Christian churches to oppose the bill.

One of them, Federico Berruete, a 35-year-old priest, joined anti-abortion demonstrators holding up slogans reading "Life starts at conception."

With such division in the country, one lawmaker from the ruling party, Daniel Lipovetzky, suggested that the matter might end up being put to a referendum.

"It's possible that we propose that," he said.

Ireland ended up overturning its own constitutional ban on abortion through a referendum held in May. That dealt a hammer blow to the Catholic Church, which is as revered in Ireland as it is in Argentina.

In mid-June, Argentina's lower house voted in favor of the bill by just 129 to 125, thanks in part to the anti-abortion President Mauricio Macri's insistence on pushing the bill through the legislature.