SAN SALVADOR (Reuters) - A Salvadoran woman accused of the attempted murder of her newborn baby under the country’s strict abortion laws after she was raped by her stepfather was freed by a court on Monday after more than 18 months in jail.

Imelda Cortez, 20, gave birth in a latrine in April 2017 and left the baby there. When Cortez was treated at a hospital afterward, doctors suspected she had tried to perform an abortion.

The court determined that Cortez, who had not known she was pregnant, did not try to kill her infant daughter. The child survived.

As she left court, Cortez, who was arrested shortly after the birth, was greeted by cheering relatives and human rights activists holding signs demanding her freedom.

Cortez’s stepfather has been arrested and is awaiting trial, Salvadoran prosecutors said.

For the past two decades, El Salvador has had some of the world’s most severe laws against women who have abortions or those who are suspected of assisting them, even when the life of the woman is at risk.

Some 22 more women are serving sentences of up to 35 years for aggravated homicide linked to abortion, according to the Group for Decriminalizing Abortion.

“This sentence ... represents hope for women who are still in prison and are also being tried for aggravated homicide,” defense lawyer Ana Martinez said.

President Salvador Sanchez Ceren in 2017 proposed a law to allow abortions in cases of rape or when the mother’s life is at risk, but Congress did not pass it.