A young rape victim who was suspected of having an abortion and charged with homicide after having a stillborn child has been acquitted by a judge at a retrial in a case that attracted international attention to El Salvador’s strict abortion laws.

Evelyn Beatriz Hernandez, now 21, had served 33 months of a 30-year prison sentence when her conviction was overturned in February for lack of evidence and a new trial was ordered. Prosecutors had asked for a 40-year sentence.

The retrial was a first for such a case in the Central American nation, where prosecutors have aggressively pursued legal cases against women who have had miscarriages or other obstetric emergencies, accusing them of murder.

“Thank God, justice was done,” Hernandez said following the announcement of the verdict, visibly emotional as dozens of women waited at the courthouse. “I also thank you who have been present here.”

“Yes we did!” the women chanted.

Hernandez also thanked foreign diplomats who have followed the case closely. The Associated Press usually does not name victims of alleged sexual assault, but Hernandez has spoken publicly about her case.

Hernandez’s foetus was at 32 weeks in 2016 when she felt intense abdominal pains and delivered it into an outdoor toilet, and it was later found lifeless in a septic tank. Her mother said she found her passed out next to the latrine, and Hernandez said she didn’t know she was pregnant.

Both women said they didn’t know there was a foetus in the tank, but prosecutors didn’t believe them and pressed charges. Forensic experts were unable to determine whether it died in the uterus or in the septic tank.

At the retrial, prosecutors’ argument against Hernandez was that she failed to protect her foetus.

Women in El Salvador hold placards that read: “Freedom, justice and reparation” and “Justice for Evelyn”
 Women in El Salvador hold placards that read: “Freedom, justice and reparation” and “Justice for Evelyn”. Photograph: José Cabezas/Reuters

“We believe the judge has been very fair in his ruling,” defence lawyer Bertha Maria Deleon said. “He has said that there was no way to prove a crime and for that reason he absolved her.”

El Salvador is one of three Central American nations with total bans on abortion. Women convicted of having abortions face sentences of two to eight years.

But women who turn up at public hospitals following a miscarriage are sometimes accused of having killed the foetus and charged with aggravated homicide, which carries a sentence of 30 to 40 years. Such punishments often fall on poor, young women and victims of rape.

“This is a resounding victory for the rights of women in El Salvador. It reaffirms that no woman should be wrongly accused of homicide for the simple fact of suffering an obstetric emergency,” said Erika Guevara-Rosas, Americas director at Amnesty International.

Guevara-Rosas called on El Salvador to cease “criminalizing women once and for all by immediately revoking the nation’s draconian anti-abortion laws.”

El Salvador is a deeply religious country with 80% of the population of six million identifying as Catholic or evangelical Christian. It’s also home to macho attitudes on women’s role in society, as well as widespread gang violence.

Every year an estimated 25,000 women are impregnated after rapes in the country. It is believed that thousands of clandestine abortions are carried out each year.