BUENOS AIRES — Argentina’s Senate on Thursday narrowly rejected a bill to legalize abortion, dealing a stinging defeat to a grass-roots movement that pushed reproductive rights to the top of the country’s legislative agenda and galvanized activist groups throughout Latin America.
The vote gripped the nation as opposing camps fought to sway undecided senators until the final hours. As legislators debated the bill into the early hours of Thursday, thousands of advocates on both sides waited outside Congress in the winter cold and the Roman Catholic Church held a “Mass for Life” at the Buenos Aires Metropolitan Cathedral.
Proponents of the bill — which would have allowed abortions in the first 14 weeks of pregnancy — had hoped Argentina would begin a sea change in reproductive rights in a largely Catholic region where 97 percent of women live in countries that ban abortion or allow it only in rare instances.
In the end, 38 lawmakers voted against the bill, 31 voted in favor of it and two abstained.
Just weeks ago, the abortion-rights campaigners appeared to have a good chance of success, stunning opponents and thrilling women’s rights advocates in nearby countries who were inspired by the battle. But opposition in Argentina hardened as Catholic Church leaders spoke out forcefully against abortion from the pulpit and senators from conservative provinces came under intense pressure to stand against the bill.
While the proposal’s defeat was considered a major setback for the activists who backed it, analysts said the movement’s improbable rise had already begun to change the region in ways that would have been impossible just years ago.
“Abortion rights was a priority and it will be deeply discouraging to have come this far and fail,” said Benjamin Gedan, an Argentina expert at the Woodrow Wilson International Center for Scholars. But he said women’s rights advocates already had achieved successes.
The Argentine campaign is credited with inspiring debate on a variety of women’s issues — including domestic violence — in a socially conservative region where such subjects have long been taboo.
On Wednesday, demonstrators rallied in support of the Argentine bill in Uruguay, Mexico, Peru, and neighboring Chile, where they gathered in front of the Argentine Embassy in Santiago, chanting and wearing the green handkerchiefs that became the symbol of Argentina’s abortion rights movement.
Activists in Argentina already have scored a victory with the passage of a law that seeks to have an equal number of male and female lawmakers.
“If we make a list of the things we’ve gained and the things we’ve lost, the list of things we’ve gained is much bigger,” said Edurne Cárdenas, a lawyer at the Center for Legal and Social Studies, a rights group in Argentina that favors legalized abortion. “Sooner or later, this will be law.”
In Latin America, only Uruguay, Cuba, Guyana, and Mexico City allow any woman to have an abortion.
On Thursday, emotions in Argentina were raw after weeks of suspense.
“We will no longer be silent and we won’t let them win,” said Jimena Del Potro, a 33-year-old designer who fought back tears. “Abortion will be legal soon. Very soon.”
Opponents expressed relief.
María Curutchet, a 34-year-old lawyer, was smiling despite spending almost eight hours in the cold to make her feelings clear.
“It was a very emotional day,” she said. “We were out in huge numbers and showed that we will defend the two lives, no matter the cost.”
For Argentina, the debate over abortion has tugged at the country’s sense of self.
It is the birthplace of Pope Francis, the leader of the world’s Catholics, who recently denounced abortion as the “white glove” equivalent of the Nazi-era eugenics program.
But the country in recent years has inched away from a close church-state relationship.
In 2010, it became the first country in Latin America to allow gay couples to wed — a move the church fought with a vigor similar to its battle against abortion, organizing protests. Francis, then the archbishop of Buenos Aires, called that bill a “destructive attack on God’s plan.”
The fight over abortion divided the political class and forced leaders to grapple with their personal and political convictions. President Mauricio Macri, a center-right leader who opposes legalized abortion, told allied lawmakers to vote their conscience and said he would sign the law if it were approved by Congress
As debates about violence against women on social media expanded into wider conversations about women’s rights, young female lawmakers gave a harder push to an abortion bill that had been presented repeatedly in the past without going anywhere.
In June, the activists scored an unexpected victory when the lower house of Congress narrowly approved a bill allowing women to terminate pregnancy in the first 14 weeks. Current law allows abortions only in cases of rape or when a mother’s life is in danger.
While the measure failed in the Senate, it made some inroads. Among the senators who voted for it was Cristina Fernandez, who as president had opposed legalizing abortion.
“The ones who made me change my mind were the thousands and thousands of girls who took to the streets,” she said before the vote.