ERBIL, Iraq (Reuters) - The battle to dislodge Islamic State from the Old City of Mosul, where hundreds of thousands of Iraqi civilians are trapped, could turn into the worst humanitarian catastrophe in the war against the militants, the United Nations warned on Tuesday.

A smoke rises as Iraqi forces fight Islamic State militants in Mosul, Iraq, April 17, 2017. REUTERS/Marko Djurica

About 400,000 civilians, or a quarter of Mosul’s pre-war population, are trapped in the Old City, according to U.N. estimates. As many as half a million are estimated to remain overall in neighborhoods still under IS control in western Mosul.

“If there is a siege and hundreds of thousands of people don’t have water and don’t have food, they will be at enormous risk,” U.N. humanitarian coordinator for Iraq Lise Grande told Reuters in a telephone interview.

“We could be facing a humanitarian catastrophe, perhaps the worst in the entire conflict.”

Mosul, the largest city in northern Iraq, was captured by the ultra-hardline Sunni Muslim fighters in mid-2014. Iraqi government forces have taken back most of it in a U.S.-backed offensive launched in October, including the half that lies east of the Tigris River.

The militants are now surrounded in the northwestern quarter including the historic Old City, countering the offensive with booby traps, suicide motorbike attacks, sniper and mortar fire, occasionally using shells filled with toxic gas.

“It is a deteriorating situation, we fear for the lives of the 400,000 people in the old city,” said Grande.

“Families ... tell us that they are being shot at as they are escaping. It’s terrifying.”

Residents who have managed to escape from the Old City have said there is almost nothing to eat but flour mixed with water and boiled wheat grain. What little food remains is too expensive for most residents to afford, or kept for Islamic State members and their supporters.

Government forces are trying to capture the Grand al-Nuri Mosque in the Old City, from where Islamic State leader Abu Bakr al-Baghdadi declared a “caliphate” spanning parts of Iraq and Syria nearly three years ago.

Troops have had the mosque, with its leaning minaret, in their sights since last month. But their progress has been painstakingly slow as the militants are dug in among civilians.

The narrow alleyways of the Old City restrict the use of suicide cars by the militants and tanks, armored personnel carriers and Humvees by the government forces.

The fighting has killed several thousands among civilians and fighters on both sides, according to aid organizations. More than 327,000 have fled in the past six months.

“The security forces know the situation on the ground and they need to decide how this is best done, whether by evacuating civilians or protecting them in their homes or opening routes they can escape through,” said Grande.