Evelyn Hernandez gave birth in April last year in the makeshift bathroom of her home in the central Cuscatlan region.
She was 18 years old and eight months pregnant.
She said her son was stillborn but a court in the city of Cojutepeque convicted her on Wednesday of murdering him, abortion rights group ACDATEE said.
A spokeswoman for the group, Morena Herrera, said Hernandez was convicted “with no direct proof” and that the court failed to take into account key forensic evidence.
ACDATEE cited a pathologist’s report which it said indicated the baby had choked to death while still in the womb.
Prosecutors argued Hernandez was culpable for not having sought prenatal care, ACDATEE said.
It said Hernandez had not known she was pregnant and gave birth on the toilet after feeling abdominal pains.
Hernandez got pregnant as the result of a rape which she did not report out of fear because her family had been threatened.
“The conviction is unjust and we are going to appeal,” Herrera told AFP.
“This case is evidence that the judicial system acts with prejudice.”
Abortion under any circumstances is illegal in El Salvador, where it is classed as aggravated homicide.
Even women who abort due to birth defects or health complications risk jail sentences of up to 40 years. Campaigners say some have been jailed after suffering miscarriages.
The country’s abortion law made international headlines in 2013 when a sick woman was forbidden from aborting a fetus that did not have a head.
Under a ruling by the Inter-American Court of Human Rights, the Salvadoran state eventually authorized that woman to undergo a Cesarean section. The baby died a few hours after the procedure.
Lawmakers presented a bill in the Salvadoran legislature in October last year proposing to decriminalize abortion. The bill has been blocked by conservative parties.