Farkhunda Malikzada was attacked at an Islamic shrine after being falsely accused of burning a copy of the Koran.
She was stoned to death, her body was run over by a car and set on fire.
The court also acquitted the keeper of the shrine. Family members and rights activists have expressed outrage at the decision, which was taken in secret.
Wednesday’s appeal court hearing in Kabul was held behind closed doors.
Judge Ali Masir Murid told the BBC that three of the condemned men had been sentenced to 20 years in jail; a fourth received 10 years because he is a minor.
One of these four men was the amulet seller Zainuddin, who had the original argument with Ms Malikzada, 27, the BBC’s David Loyn in Kabul reports. The caretaker of the shrine, Omran, was acquitted, he adds.