BAGHDAD, May 19 (Reuters) - Islamic State fighters who overran Ramadi in a major defeat for the Iraqi government and its Western backers tightened their grip on the city, flying back flags on key buildings and setting free prisoners in a drive to win the support of local residents.
After Ramadi fell on Sunday, Shi'ite militiamen in armored vehicles deployed to a nearby base in preparation for a counterattack to retake the city, which lies just 110 km (70 miles) northwest of Baghdad.
Witnesses in Ramadi said Islamic State fighters had set up defensive positions and laid landmines.
They were also going from house to house in search of members of the police and armed forces and said they would set up courts based on Islamic Sharia law.
Iraqis who fled Ramadi arrive at the outskirts of Baghdad, April 19, 2015.
They released about 100 prisoners from the counter-terrorism detention center in the city.
Saed Hammad al-Dulaimi, 37, a school teacher who is still in the city, said: "Islamic State used loudspeakers urging people who have relatives in prison to gather at the main mosque in the city center to pick them up. I saw men rushing to the mosque to receive their prisoners."
The move could prove popular with residents who have complained that people are often subject to arbitrary detention.
Sami Abed Saheb, 37, a Ramadi restaurant owner, said Islamic State found 30 women and 71 men in the detention center. They had been shot in the feet to prevent them escaping when their captors fled.
Witnesses said the black flag of Islamic State was now flying over the main mosque, government offices and other prominent buildings in Ramadi.
Jasim Mohammed, 49, who owns a women's clothing shop, said an Islamic State member had told him he must now sell only traditional Islamic garments.
"I had to remove the mannequins and replace them with other means of displaying the clothes. He told me that I shouldn't sell underwear because it's forbidden," he said.
Islamic State had also promised that food, medicine and doctors would soon be available.
A member of Iraq's anti-terrorism forces stands guard outside the Habaniyah military base near Ramadi on May 8, 2015.
Dulaimi saw Islamic State fighters using cranes to lift blast walls from the streets and bulldozers to shovel away sand barriers built by security forces before they fled.
"I think they (Islamic State) are trying to win the sympathy of people in Ramadi and give them moments of peace and freedom.
"But we are sure that this is only temporary and won't last for long because the worst is yet to come and we will end up trapped in the cross fire when government and Hashid forces start their attack to recapture Ramadi," he said.
The decision by Prime Minister Haider al-Abadi, who is a Shi'ite, to send in the militia, known as Hashid Shaabi or Popular Mobilization, to try to retake the predominantly Sunni city could add to sectarian hostility in one of the most violent parts of Iraq.
The Abadi government had pledged to equip and train pro-government Sunni tribes with a view to replicating the model applied during the "surge" campaign of 2006-07, when U.S. Marines turned the tide against al Qaeda fighters - forerunners of Islamic State - by arming and paying local tribes in a movement known as the Anbar Awakening.
Iraqi Shiite militia fighters stand guard outside their headquarters in Basra on May 18, 2015.
But a repeat will be more difficult. Sunni tribal leaders complain that the government was not serious about arming them again, and say they received only token support.
There are fears that weapons provided to Sunni tribes could end up with Islamic State. Islamic State has also worked to prevent the emergence of a new Awakening movement by killing off sheikhs and weakening the tribes.
Iraqi ministers on Tuesday stressed the need to arm and train police and tribal fighters. Abadi called for national unity in the battle to defend Iraq.
"ISIS cannot continue to hold the territories it has seized in the face of the persistence and greatness of Iraqis," he said.
Experts have warned of the danger to the wider Middle East posed by Islamic State's gains in Ramadi and Anbar province.
"If Anbar were to fall completely under the control of IS then the stability of Iraq as a whole can no longer be guaranteed and if Iraq were to fall the entire region would be pushed further towards complete failure," said Natasha Underhill of Nottingham Trent University.
Iraqi children who fled Ramadi at a camp for displaced families in Bzeibez on May 18, 2015.
A spokesman for Iraqi military operations, Saad Maan, said the armed forces controlled areas between Ramadi and the Habbaniya military base about 30 km (20 miles) away where the militia fighters are waiting.
"Security forces are reinforcing their positions and setting three defensive lines around Ramadi to repel any attempts by terrorists to launch further attacks," Maan said.
"All these three defensive lines will become offensive launch-pads once we determine the zero hour to liberate Ramadi."
The International Organization for Migration said 40,000 people had been forced to flee Ramadi in the past four days.
About 500 people were killed in the fighting for Ramadi in recent days, local official said.
Islamic State gains in Ramadi mean it will take longer for Iraqi forces to move against them in Mosul, where militants celebrated victory in Anbar by firing shots into the air, sounding car horns and playing Islamic anthems, residents said.
(Reporting by Baghdad Bureau; Additional reporting by Stephen Kalin; Writing by Giles Elgood; editing by Janet McBride)