MISRATA, Libya (Reuters) - Libyan authorities released on Wednesday 28 Eritreans and seven Nigerians who were captured and enslaved by Islamic State in Sirte and had been held in detention since the jihadist group lost the city in December.

FILE PHOTO: An Eritrean migrant touches a ring on her hand at a military building in Misrata, Libya, November 6, 2016. REUTERS/Ismail Zitouny

The group, all but two of whom are women and children, escaped from Sirte, a former Islamic State stronghold in central Libya, while forces from the nearby city of Misrata battled to oust the militants late last year.

Some of the women were on their way to Europe when Islamic State fighters kidnapped and held them as sex slaves.

After they escaped from Sirte, they were investigated for possible ties to the group and held for several months in a Misrata prison.

Reuters has documented how Islamic State used enslaved refugee women to reward its fighters in Libya. In stories published last year, the women recounted how the group forced them to convert to Islam and sold them as sex slaves.

In November, a Reuters reporter visited some of the captives at a military post in Misrata. Their new captors, the women said then, starved and humiliated them. At least one woman, a 16-year-old, was pregnant and in need of urgent care.

The Libyan attorney-general’s office announced that it had cleared the women of any wrongdoing in mid-February, but their release was delayed for several more weeks, with no explanation.

On Wednesday, they were received by staff from the U.N. refugee agency (UNHCR) and the Libyan Red Crescent, before being taken to a shelter for medical checks.

“I’m very happy, I can’t describe how I feel, but I am very happy, I can start a new life and see my family again,” one 14-year-old Eritrean girl told Reuters before leaving the prison with the rest of the group on a Red Crescent bus.

A UNHCR official said the entire group had scabies, but otherwise appeared to be in reasonable physical condition.

The agency expects to resettle the Eritreans as refugees.

“We will send them to a safe house where they can be treated if they need medical treatment, and receive assistance from us, and be protected,” said Samer Haddadin, head of the UNHCR’s Libya mission.

“At the same time we will be processing them for refugee status determination ... and we are doing this to make sure we can find a resettlement country for those who meet the resettlement criteria.”

The Nigerians, five women and two children, will be able to apply for asylum or be offered repatriation.

Dozens of women and children who escaped from Sirte or were picked up there by Libyan forces are still being held in Misrata. They include Libyans, Tunisians, and nationals from several sub-Saharan African countries. A group of Filipino nurses were freed in February.

Islamic State took control of Sirte in early 2015, turning the coastal city into its most important base outside Syria and Iraq and stationing hundreds of foreign fighters there. It took Misrata-led forces almost seven months to recapture the city.