Gunmen stormed a midwife training centre in the eastern Afghan city of Jalalabad on Saturday, fighting security forces for several hours and killing three staff.
One of the attackers died early in the operation after detonating a suicide bomb but a second held out for several hours before being killed, provincial government spokesman Attaullah Khogyani said.
A driver and two security guards were killed and seven people were wounded but 63 other people, almost all women, were rescued unharmed from the compound, which contained a training facility and a student residence.
Gunfire and sporadic explosions were heard during much of the day and clouds of black smoke rose from the area.
There was no immediate claim of responsibility but a number of recent attacks have been claimed by Islamic State, which has a stronghold in the surrounding province of Nangarhar, on the border with Pakistan.
It was not immediately clear why the attackers had targeted the facility, which was mainly occupied by trainee midwives from the eastern province of Nuristan.
Track Latest News Live on NDTV.com and get news updates from India and around the world