Social workers say there are thousands more in other towns and provinces liberated from the Islamic State.

They say that 20,000 would be a conservative estimate for the total. The number includes children who have lost just one parent, who Iraqis also classify as orphans because single parents in this culture cannot simultaneously serve as breadwinner and caregiver.

Most of these children have since been placed with their extended families.

Dozens of such families interviewed in Mosul say they are overwhelmed by this duty, lacking the services of social workers, money for medical care and support for their own emotional traumas as survivors of war. They search, often in vain, for help from underfunded government agencies, and local charities.

Those without any family are left at the Mosul orphanage, a government shelter that the Islamic State had appropriated as an austere barracks for teenage soldiers when it ruled Mosul.

This spring, the orphanage director, Ghazwan Muhammad, and his staff of seven social workers, nurses and cooks reopened the home to give 50 children a place to live. They spent months without pay transforming the buildings, painting the nursery bright colors, canvassing businesses for donations of toys and blankets, and trucking in new playground equipment. They started to receive government funding in June.

The orphans there include children of victims of the Islamic State, like Muhammad, as well as the children of members of the Islamic State, also known by its Arabic acronym, Daesh. They also include 17 newborns abandoned by their mothers, staff members assume, because of the stigma of raising the child of a militant.