Argentina’s senate has rejected a bill which would have legalised abortion in the first 14 weeks of pregnancy.

After a marathon debate, 38 senators voted against it and 31 in favour. Its defeat means lawmakers must wait until next year to resubmit legislation.

Currently abortion is allowed in Argentina only in cases of rape, or if the mother’s health is in danger.

Demonstrators on both sides of the debate rallied outside parliament as voting took place.

Anti-abortion activists have been jubilant. “What this vote showed is that Argentina is still a country that represents family values,” one told the Reuters news agency.

Pro-choice campaigners say they are not giving up. Some started fires and lobbed missiles at police after the vote.

Pro-choice campaigners have for years tried to get bills passed in Argentina, where the population is overwhelmingly Roman Catholic.

Their efforts gained new impetus when President Mauricio Macri – who opposes abortion – called on Congress to consider a vote on it, and it narrowly passed in the lower house.

The debate in the Senate lasted more than 16 hours in an often fraught session. Argentine Vice President Gabriela Michetti, who also opposes abortion, was heard swearing at colleagues without realising her microphone was on,

Former President Cristina Fernández de Kirchner, who is now a senator and who had refused to back the legalisation of abortion while president, supported the bill, saying her mind was changed by the thousands who took to the streets.

There are 42 men in the Argentine senate and 30 women. Among the women the vote was evenly split while a majority of men voted against.

“This law doesn’t obligate, nor does it recommend anyone have an abortion. The only thing this law does is defend the right to choose.” Norma Durango, from the opposition Peronist party

“The message that we wanted to put across is that abortion equals social failure. For a woman to resort to it, many other things need to have failed first.” Camila Duro of the anti-abortion non-governmental organisation Frente Joven

“Abortion always kills a child and it doesn’t solve the woman’s problem. We believe that this is never the solution. Faced with an unexpected pregnancy abortion is never the solution. There are always other solutions.” Maria Castillo, who campaigned outside parliament

For the bill’s advocates, legalising abortion is an urgent public health matter. Tens of thousands of women in Argentina are taken to hospital every year after illegal abortions. In 2016, 43 women died.

Those that can afford it use drugs to terminate their pregnancies while poorer women turn to far cruder methods.

Uruguay and Cuba are the only Latin American nations to have decriminalised abortion. It is largely prohibited across the region except in restricted cases.

The Supreme Court in Latin America’s most populous country Brazil has begun hearing from both sides on whether abortion should be legalised up to 12 weeks.

In May, another largely Catholic country, the Republic of Ireland, voted overwhelmingly in a referendum to overturn a ban on abortion.(BBC News)