BAGHDAD — After months of sluggish progress, stalled advances and outright failures, Iraqi troops and militias backed by U.S.-led airstrikes have surrounded the key city of Ramadi and appear poised to launch a new attempt to wrest it from the Islamic State group.

The battle that is shaping up threatens to turn into a drawn-out siege, with thousands of residents caught in the middle as the forces try to wear down the militants since they took over the capital of western Anbar province in May. Western officials and analysts warned that the strategy of a methodical, slow siege could make the fight even more difficult.

On Monday, the Iraqi military dropped leaflets into the city, telling the remaining residents – estimated at anywhere from 4,000 to 10,000 – to leave, the strongest signal yet that an assault is imminent.

But residents told The Associated Press on Tuesday that the militants have clamped down, setting up checkpoints across the city to monitor civilians’ movements and prevent anyone from going.

“Loudspeakers from mosques give warnings that civilians are not allowed to leave, and anyone who tries to do so will be either arrested or killed,” one resident said, speaking on condition of anonymity for fear for his safety.

Ramadi, like the rest of Anbar province, is overwhelmingly Sunni Muslim, the minority community that complains of discrimination by the Shiite-led government in Baghdad. Some Sunnis in other parts of Anbar and in northern Iraq welcomed rule by the Islamic State group – also known as ISIS or ISIL and its Arabic acronym Daesh – at least initially.

Resentment of the extremists has been stronger in Ramadi, but some residents worry about the cost of dislodging the Islamic State.

“Of course we want this to end,” another resident said, referring to Islamic State rule and the government siege. But he said he also fears increased airstrikes and clashes, with him and his family unable to escape.

The Islamic State group’s capture of Ramadi was an embarrassing blow to the Iraqi military. The two sides had been battling over it since the previous summer. But in May, the militants unleashed a wave of suicide bombings that stunned the city’s defenders, and police and troops collapsed and fled. The jihadis swept in and took control, raising their black banner over the main government headquarters.

The city became part of the large swath of territory the extremists hold in Iraq, including almost all of Anbar province and the northern city of Mosul, linked with areas of northern and eastern Syria that they also control.

For several months, Iraqi troops and an umbrella group of militias – mainly Shiites – have been fighting in Anbar.