Argentina's Senate has rejected a bill to legalise elective abortion in the first 14 weeks of pregnancy, an issue that has divided the homeland of Pope Francis.
Lawmakers debated for more than 15 hours and voted 38-31 against the bill on Thursday.
The decision could echo across Latin America, where the Roman Catholic Church has lost influence and moral authority due to secularisation, an out-of-touch clerical caste and an avalanche of sex abuse scandals.
For long hours, thousands of supporters wearing green handkerchiefs that represent the effort to legalise abortion and opponents of the measure wearing light blue, braved heavy rain and cold temperatures to watch the debate on large screens set up outside Congress.
The demonstrations were largely peaceful, but after the vote, small groups of protesters clashed with police, throwing firebombs and setting up flaming barricades. Police officers responded with tear gas.
The lower house had already passed the measure and conservative President Mauricio Macri had said that he would sign it, even though he is anti-abortion.
In Argentina, abortion is only allowed in cases of rape and risks to a woman's health. Thousands of women, most of them poor, are hospitalised each year for complications linked due to unsafe illegal abortions.
The Health Ministry estimated in 2016 that the country sees as many as half a million clandestine abortions each year, with dozens of women dying as a result.
The Catholic Church and other groups oppose it, saying it violates Argentine law, which guarantees life from the moment of conception.
The contentious issue has divided Argentines, pitting conservative doctors and the Catholic Church against feminist groups and physicians.
"It's not about religious beliefs but about a humanitarian reason," Cardinal Mario Poli, the archbishop of Buenos Aires, told churchgoers at a "Mass for Life" at the capital city's Metropolitan Cathedral on Wednesday.
"Caring for life is the first human right and the duty of the state."
Pope Francis this year had denounced abortion as the "white glove" equivalent of the Nazi-era eugenics program and urged families "to accept the children that God gives them."
"Let's recognise that we're facing a public health tragedy because 3030 women who have died is a tragedy," said Magdalena Odarda, a senator for Rio Negro province.
"We're not deciding abortion yes or now. We're deciding abortion in a hospital, or illegal abortion, with a clothes hanger, or anything else that puts a woman in a humiliating, degrading situation - a real torture," she said.
For months, hundreds of doctors in Argentina had staged anti-abortion protests, in one case laying their white medical coats on the ground outside the presidential palace.
Feminists and other groups led even larger demonstrations in support of the measure, often wearing green that symbolises the pro-abortion movement, or red cloaks and white bonnets like the characters from the novel-turned-TV series The Handmaid's Tale.