MOSUL/BEIRUT (Reuters) - Western-backed forces edged into the final redoubts of the two capitals of Islamic State’s self-declared caliphate in Iraq and Syria on Tuesday, hampered by fierce resistance from the militants and the presence of human shields.

Iraqi commanders have predicted final victory in Mosul this week after a grinding eight-month assault on the once two-million-strong city pushed Islamic State into a rectangle no more than 300 by 500 meters beside the Tigris river.

In Raqqa, Islamic State’s headquarters in northern Syria from where it plotted attacks around the world, U.S.-backed militia were fighting inside the historic Old City after coalition air strikes breached its walls in two places.

Victory over the hardline militants in both cities would mark the effective end of the three-year-old caliphate, although a few towns and large rural areas of Iraq and Syria remain under their control.

But their centers are a maze of narrow alleyways packed with civilians and planted with multiple explosive devices by the militants, who are also using drones and suicide bombings.

“The presence of civilians has affected the troops’ advance a lot,” said a commander in Mosul from the Rapid Response Division, an elite Interior Ministry unit, estimating there were 10,000 civilians, including some brought in as human shields.

Iraqi commanders called in air strikes on targets just 50 meters away from them and fighting got close enough at one point for the militants to throw a hand grenade at the troops.

Slideshow ( 13 images )

“The directions from the commander-in-chief of the armed forces are to advance slowly to preserve civilians’ lives and this is what we are doing,” the officer said on Iraqi state TV without being named.

MINES AND DRONES

The U.S.-led international coalition supporting the Iraqi military and the Syrian Democratic Forces (SDF) fighting Islamic State in Raqqa said it had been forced to bomb the Old City’s ancient wall because the militants were controlling the existing breaches.

“SDF fighters would have been channeled through these locations and were extremely vulnerable as they were targeted with vehicle-borne IEDs (car bombs) and indirect fire as well as direct fire from heavy machineguns, rocket-propelled grenades and snipers as they tried to breach the Old City,” it said.

The assault on Raqqa, which began last month, was going to plan, though Islamic State’s use of motion sensor-triggered mines and drones that drop bombs had slowed down operations a little, an SDF spokesperson said by telephone.

SDF fighters had seized an ancient palace, Qasr al-Banat, in the eastern part of the Old City, an SDF statement said.

Slideshow ( 13 images )

On Thursday, Iraqi forces retook Mosul’s mediaeval Grand al-Nuri mosque from where Islamic State leader Abu Bakr al-Baghdadi declared the caliphate, prompting Prime Minister Haider al-Abadi to declare an end to what he called a “state of falsehood”.

Baghdadi is believed to be hiding near the Iraq-Syrian border, according to U.S. and Iraqi military sources and the number of Islamic State militants fighting in Mosul and Raqqa has dwindled from thousands to hundreds.

Iraqi authorities are planning a week of nationwide celebrations to mark the end of the offensive and Abadi is expected to visit Mosul to formally declare victory.

Hundreds of thousands of people have fled Mosul and Raqqa, which have been devastated by the fighting, creating the challenges of rebuilding and preventing revenge attacks on suspected Islamic State sympathizers that could sow the seeds of a new ultra-hardline movement.