Imelda Cortez (R) is accompanied by relatives after she was acquitted and released. Cortez got pregnant after she was raped by her stepfather.
USULUTAN - A judge in El Salvador on Monday acquitted a 20-year-old rape victim originally charged with murder after giving birth prematurely in a toilet.
Imelda Cortez's daughter survived but the woman was charged homicide after the baby was found in a septic tank.
It was seen as a landmark case by women's rights groups in El Salvador, where abortion is completely banned and women can face up to 40 years in prison, even for a miscarriage.
A court in the southeastern city of Usulutan "absolved" Cortez, her defense lawyer Bertha Maria Deleon wrote on Twitter.
A spokesman from the La Casa de Todas feminist group confirmed to AFP that Cortez was "free."
Cortez fell pregnant to her stepfather, who allegedly raped her repeatedly over a seven-year period.
She has already spent more than a year and a half behind bars awaiting trial.
The case took a dramatic turn when prosecutors changed the charge against her from homicide to "abandonment and neglect."
"We know that Imelda didn't commit any crime," one of Cortez's lawyers, Keyla Caceres told AFP earlier.
The premature birth was discovered after Cortez sought hospital treatment in April 2017 for a haemorrhage.
Doctors examining her took out the placenta.
Cortez said she'd felt something come out of her when using the bathroom.
Police and soldiers inspected the septic tank at Cortez's house and found a crying baby "covered in faeces and white dust," according to legal authorities.
The baby was taken to hospital and survived.
El Salvador has some of the toughest anti-abortion laws in the world, banning the process even in cases of rape or when a mother's life is at risk.
Caceres said Cortez was representative of "girls and young adolescents whose human rights are completely violated" by the country's unforgiving abortion laws.