Some of those escapees have become top leaders of the Islamic State of Iraq and Syria, now a Qaeda splinter group that has taken on an active, and brutal, role in the civil war in Syria and the rising insurgency in Iraq. Many other escapees have filled the fighting ranks of the group in both countries, along with militants who have escaped from other Iraqi jails in recent times.

The government had apparently been emptying the prison over several nights, under protection of special forces soldiers, during a curfew in which vehicles are prohibited from traveling from midnight to 4 a.m., according to a security official.

Since the beginning of the year, insurgents have controlled Falluja and other areas of Anbar, including sections of Ramadi, the provincial capital. The Iraqi Army, which has sought to use loyal tribesmen inside Anbar communities as proxy fighters, giving them American-supplied guns and ammunition, has held off on a full-out assault. But after three months, the fighting still rages, and the Iraqi security forces have appeared to make few gains. Tens of thousands of Anbar residents have been displaced, some fleeing to southern Iraq, some to Baghdad and others to the relative safety of the Kurdish north.

Last year, nearly 8,000 Iraqi civilians and were killed in attacks, according to the United Nations, the highest level in at least five years. This year, more than 2,000 civilians were killed through the end of March, the United Nations says, but deaths from the fighting in Anbar were not included because it is too difficult to monitor the situation.

Lately, the fighting has crept closer to the Abu Ghraib prison, with frequent gunfights in the streets near the compound, said a security official, leaving villagers caught in the crossfire.

A local grocer, who would give only his first name, Ahmed, said in an interview on Tuesday: “We heard today that they have closed the prison, but what about us, the people of Abu Ghraib? What will happen to us? Will they transform us into another country if they can’t protect this area?

“We see gunmen in the streets every day, and a few hours later we see the security forces. We don’t know what is happening here.”