When the Iraqi government declared victory on Sunday after routing Islamic State gunmen from the key city of Fallujah, it cleared a major hurdle on the way to a much larger and more complicated fight for the ISIS-held city of Mosul in northern Iraq.

The victory in Fallujah deprives ISIS of an important territorial asset, a city 40 miles west of Baghdad from which jihadists directed a lethal campaign of car bombings in the capital. Now all eyes turn north, toward Mosul, the largest city still under ISIS control and the most significant strategic prize in the land campaign against the terror group.

Read More: The Next War for Iraq

The recapture of Fallujah provides hints—some promising, some foreboding—about how the fight for Mosul might proceed. The operation demonstrated how rival U.S. and Iranian-backed forces can avoid conflict and even cooperate in the battle against ISIS, but major questions remain about how to secure and rebuild Fallujah, resettle the tens of thousands of civilians who fled the fighting and establish a sustainable peace in a city that has long been riven by sectarian divisions.

Aid agencies have expressed alarm about the ongoing plight of at least 84,000 people currently displaced from Fallujah. Without a safe pathway out of the city, civilians fleeing the recent battle were forced to brave gunfire and explosives in the streets. Some drowned while crossing the Euphrates River. Even those who managed to escape are now stranded in the searing summer heat in camps outside the city with limited supplies of food, water, and medicine.

Following the chaotic exodus of civilians from Fallujah, aid organizations say more needs to be done to prepare for the even larger flow of displaced people that will result from any battle in Mosul, where an estimated 600,000 people are currently living under ISIS rule. That means establishing a safe route for civilians to exit and ensuring a humanitarian infrastructure is in place before the battle begins.

“If we struggled to cope with Fallujah, then God help us with Mosul,” says Karl Schembri, a spokesperson in Baghdad for the Norwegian Refugee Council, a leading aid group. “Right now it’s just unthinkable. Right now with the current resources that all agencies have—it’s not just us, and the U.N. itself—nobody in his right mind can say that we are prepared for Mosul.”

Among the many challenges facing Iraqi authorities is keeping ISIS operatives from infiltrating government-held territory by slipping in among fleeing civilians. But doing so carries major human rights risks—Iraqi forces routinely separated men from women fleeing Fallujah, leading to the reported disappearance of hundreds of men. According to Human Rights Watch, there is also evidence that pro-government forces also tortured detainees and in one case summarily executed more than a dozen civilians.

Evidence compiled by rights groups suggests that some of the abuses were carried out by government forces such as the Federal Police. Others were the fault of government-allied, Shiite-dominated militias called Popular Mobilization forces. Organized in 2014 as a bulwark against ISIS after the Iraqi national army collapsed, the Popular Mobilization groups now play a central but controversial role in the civil war. Critics accuse the Shiite-dominated militias of punishing ordinary Sunni civilians. The leaders of the militias deny those charges, but there’s no doubt that using Shiite militias to fight the Sunni jihadists of ISIS risks alienating ordinary Sunni Iraqis.

In Fallujah, Iraqi leaders can look to some positive signs. Pro-government forces retook the city after nearly five weeks of fighting. The battle ended more quickly than expected as ISIS forces abandoned the area. Some observers had feared a repeat of the intense urban warfare experienced by U.S., Iraqi, and British troops fighting a Sunni-led insurgency there in 2004, one of the deadliest battles in the nearly decade-long U.S.-led occupation.

Analysts say the fight for Fallujah was also an example of coordination among rival forces, including U.S.-trained troops and pro-Shiite militias that lean toward Iran. In Fallujah, Iraqi police, special forces and Popular Mobilization forces all participated in the battle—and in a surprisingly harmonious way.

Before the launch of the operation in May, massive protests against the government of Prime Minister Haider al-Abadi spurred the competing forces toward coordination, according to Maria Fantappie, a senior analyst with International Crisis Group. “When the domestic crisis unfolded, there was, I think, a renegotiation in an indirect way between the two sides over this issue,” says Fantappie, speaking by phone from Iraq.

A rough division of labor emerged, with Iran-backed forces deployed on the northwest outskirts of the city and U.S.-backed forces in the south. “There was a sort of understanding of who should be where, and that actually allowed the operation to unfold,” she says.

But in Mosul the political puzzle is even more complicated, with the Iraqi national army, U.S. military and pro-Shiite militias all expected to play different roles. Adding yet another layer of complexity, Mosul is flanked on three sides by Kurdish forces who do not answer to the central government in Baghdad. Before the battle for Mosul can begin in earnest, the government must reach an understanding with the Kurdish regional government based in the city of northern Erbil. The two leaderships have yet to decide the exact role Kurdish forces will play in the battle, including how close they will get to the center of the majority Arab city. Because Mosul lies close to Kurdish-controlled land, any negotiations over the future of the city will trigger delicate questions of Kurdish aspirations for greater autonomy or even full independence.

The battle for Mosul will also be far larger than the effort to liberate Fallujah, and the Iraqi government’s current military campaign in the north is unfolding at a halting pace as the army recaptures villages one by one along the Tigris River south of Mosul. With some exceptions, Kurdish forces are holding static front line positions, awaiting orders for the final battle. Officials and analysts say an attack on the city of Mosul is months away at least, if not longer.

Ultimately defeating ISIS in Sunni-majority cities like Fallujah and Mosul will also require reestablishing a social contract with Iraq’s minority Sunni Arab citizens, many of whom feel neglected by the Shiite-dominated central government in the years since the toppling of dictator Saddam Hussein in the U.S. invasion of 2003.

“ISIS emerged as a matter of an intra-Sunni leadership problem. A Sunni leadership that was increasingly less legitimate was pushed out by another Sunni leadership,” says Fantappie. “You can reconstruct infrastructure. You can deal with the humanitarian problem, but it should also be thought through, how you can solve this intra-leadership problem.”

Get The Brief. Sign up to receive the top stories you need to know right now. Please enter a valid email address. Sign Up Now Check the box if you do not wish to receive promotional offers via email from TIME. You can unsubscribe at any time. By signing up you are agreeing to our Terms of Use and Privacy Policy . This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply. Thank you! For your security, we've sent a confirmation email to the address you entered. Click the link to confirm your subscription and begin receiving our newsletters. If you don't get the confirmation within 10 minutes, please check your spam folder.

Contact us at letters@time.com.