ERBIL, Iraq — The Iraqi military’s operation to retake the northern city of Mosul after more than two years of Islamic State occupation could require months, even with American help. But the recapture may turn out to be the easy part.  If history is a guide, vast parts of Mosul, once Iraq’s No. 2 city with about two million inhabitants, could be left in smoldering ruins by retreating or die-hard Islamic State fighters who may use remaining civilians as shields and booby-trap entire neighborhoods with improvised bombs. Just clearing these explosives could take months or years.  Three other important Iraqi cities recaptured from the Islamic State — Ramadi, Tikrit and Falluja — were left in varying degrees of devastation. Here is a look at what happened to each:  Much of Ramadi was obliterated in the Iraq military’s prolonged campaign to retake it.  Captured by Islamic State: May 2015  Recaptured by Iraqi military: December 2015  Ramadi, the capital of heavily Sunni Muslim Anbar Province, about 70 miles west of Baghdad, once had a population of at least a half million. Although occupied by the Islamic State for only half a year, much of the city was obliterated in the Iraqi military’s prolonged campaign to retake it, which included hundreds of bombing runs by American warplanes and block-by-block combat with Islamic State fighters who created a network of underground tunnels and hide-outs. Many residents fled, staying in camps for internally displaced people administered by the United Nations and other aid groups.  Today, 10 months after Iraq’s Shiite-led government proclaimed Ramadi liberated, parts of the city remain unlivable because of bombs and other dangerous remnants of war ensconced in the rubble or deliberately placed in vacant schools, homes and hospitals. The Iraqi prime minister’s office estimated that 90 percent of Ramadi was contaminated with explosives when the Islamic State was defeated. The United Nations has estimated the cost of decontamination to be as much as $200 million, but others call this estimate unrealistically low. Rebuilding costs are estimated in the billions.  Lisa Grande, the top United Nations humanitarian aid coordinator in Iraq, said about 300,000 people had returned to Ramadi, but basic services had not been fully restored. Bickering between Sunni factions in the city and efforts to remove the provincial governor from his post have slowed rebuilding.  Officials at the State Department’s Office of Weapons Removal and Abatement, which has overseen American efforts to help decontaminate Iraq of explosives, said the priority in Ramadi has been to clear explosive remnants of war, known as ERW, from schools, hospitals and critical facilities like water treatment plants.  Despite some progress, State Department officials said it would be premature to describe Ramadi as returning to normal.  “To clear Ramadi of every piece of ERW, you’re talking about a yearslong effort, hundreds of millions of dollars, well beyond what we have,” said Jerry Guilbert, the office’s deputy director for programs.  Captured by Islamic State: June 2014  Recaptured by Iraqi military: April 2015  Tikrit, Saddam Hussein’s hometown, about 100 miles north of Baghdad, was the first major test of the Shiite-led government’s ability to repopulate Sunni areas taken from the Islamic State. The effort went relatively well: Most of the roughly 150,000 residents who had fled returned within a few months.  The first returnees, however, found a city with basically no services. Shiite militiamen had looted parts of Tikrit, the main hospital was destroyed, and unexploded ordnance lurked in areas that had been ravaged by combat.  The government opened bakeries and provided residents with rice and cooking oil. Shiite militias even escorted displaced Sunni families back to their homes, and security in the city was quickly turned over to local Sunni men. The government had a hand in reconciliation efforts between tribes, in which blood money was paid to settle feuds from when the Islamic State was in control.  Ms. Grande said that Prime Minister Haider al-Abadi directed a well-organized rebuilding effort in Tikrit led by the federal government — something that has not been replicated elsewhere.  Captured by the Islamic State: January 2014  Recaptured by Iraqi military: June 2016  Falluja, a restive Sunni-dominated city less than 40 miles from Baghdad, was the first to fall to the Islamic State and has been an important incubator for Sunni extremism.  The Iraqi effort to retake Falluja left it less devastated than Ramadi. Even so, weeks of indiscriminate shelling by Shiite militias, as well as fierce fighting in the final weeks of the assault, left sections of the city in rubble.  Before Iraqi forces proclaimed victory in June, officials estimated that 90,000 civilians were in Falluja; the city’s population at its height was close to 300,000. Ms. Grande said more than 70,000 had since returned.  Once recaptured, Mosul could pose a far more complicated rebuilding challenge, given that it is so much bigger than other Islamic State conquests and was much more diverse, with Christian, Kurdish and Shiite minorities.  “The big difference between Mosul and the cities of Ramadi and Falluja is the size of the city,” Ms. Grande said.  In Washington, officials said on Tuesday that it was difficult to draw definitive conclusions from the first 48 hours of combat, but analysts were already noting possible trends.  Initial resistance from Islamic State fighters has been less than anticipated, despite heavy fighting in the southern and eastern approaches to the city and nearly a dozen suicide car bombs directed at advancing forces.  Ibrahim al-Marashi, an assistant professor of history at California State University, San Marcos, and an expert on Iraq’s military, said the Islamic State had a lot more time to build defenses in Mosul than in other Iraqi cities, raising the risk of intense destruction during a siege.  “Just in the sheer volume of fighting, a battle of this scale has never been done before in Iraq,” he said. “It doesn’t bode well for Mosul.”  Follow Tim Arango @tarangoNYT and Rick Gladstone @rickgladstone on Twitter.  Tim Arango reported from Erbil, and Rick Gladstone from New York. Eric Schmitt contributed reporting from Washington.  A version of this article appears in print on October 19, 2016, on page A8 of the New York edition with the headline: Recapturing Mosul From ISIS May Pale to What Comes Next. Order Reprints| Today's Paper|Subscribe
If the recaptures of Ramadi, Tikrit and Falluja are a guide, Iraqi officials will confront devastation and unexploded bombs once Mosul is reclaimed.