Senators in Argentina have voted against legalising abortion in the homeland of Pope Francis.
The vote dashed the hopes of women's rights groups after the bill was approved by the legislature's lower house in June.
According to an official tally, 38 senators voted against the measure to legalise the termination of a foetus during the first 14 weeks of pregnancy, 31 were in favour, while two abstained.
The vote was welcomed by fireworks and shouts of joy among anti-abortion activists gathered outside of Congress.
At the other end of the square, tears were seen streaming down the faces of pro-abortion advocates, many wearing the green scarves that had come to symbolise their cause.
A handful of demonstrators started fires and threw stones as they clashed with riot police who responded with tear gas and water cannon.
The vote came after months of fiercely polarised campaigns on the 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.
Politicians must now wait a year to resubmit the legislation.
Miguel Angel Pichetto, a Peronist opposition leader who supported the legislation, said 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.
Earlier in the day, scores of buses had brought people from around the country into Buenos Aires for the competing rallies outside Congress.
Abortion rights supporters wore green scarves while anti-abortion activists donned baby blue. A partition was set up to keep them separated.
Current Argentine law only permits abortions in cases of rape or if the mother's health is at risk.
The bill had sought to legalise 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 decriminalise 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.
In mid-June, Argentina's lower house voted in favour 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.