The woman, who has always maintained that she was unaware of the pregnancy, was arrested, tried, and sentenced to 30 years in jail for aggravated homicide under El Salvador's strict abortion laws.
In 2018 a higher court overturned this ruling and ordered a re-trial, with prosecutors asking for a 40-year sentence.
Abortion is illegal under all circumstances in El Salvador. In 2018, two proposals for modifications to the law to permit abortion in cases of rape, grave fetal malformations, or risks to the health of the mother failed to gain enough support to bring a vote in parliament.
"Thank God justice was done," Hernandez told journalists and supporters after she left the courthouse in Cojutepeque, about 30 kilometres east of the capital San Salvador.
"This is a resounding victory for the rights of women in El Salvador," Amnesty International Americas Director Erika Guevara-Rosas said in a statement.
"Now that Evelyn has been acquitted, Amnesty International calls on El Salvador to end the shameful and discriminatory practice of criminalizing women once and for all by immediately revoking the nation’s draconian anti-abortion laws," she added.
El Salvador President Nayib Bukele, who took office in June, pledged a softer approach to abortion.
-----------------------------------------------------------------------------------------