It’s been clear from the start that the American and Iraqi-led battle to retake Mosul from the Islamic State presented a logistical and strategic puzzle — even a possible nightmare — in which the interests of multiple countries and sectarian groups had to be reconciled and their roles carefully coordinated. Without such coordination, the effort to defeat ISIS and liberate thousands of Mosul residents who have suffered horribly under the terrorist group for two years would be severely undermined.

The nightmare scenario has now become more likely with Turkey’s decision to pick a fight with Iraq. Turkey’s president, Recep Tayyip Erdogan, is demanding a direct role in the battle that no one had designed for his troops, meanwhile seeming to tread on Iraq’s sovereignty.

This is a troubling development because if Mr. Erdogan persists, leaders of Iraqi Shiite militias may follow through on their threat to join the battle. Before the fighting started last week, the United States had worked with the Iraqis to assemble a military force that included the Iraqi Army, Kurdish forces and Sunni tribal fighters — but not the Shiite militias, which have a record of abuses against Sunnis, the largest religious group in Mosul.

Even before this latest demand, Turkey had angered Baghdad by keeping 600 to 800 troops at a base in Bashiqa in northern Iraq. Ankara’s real priority is defeating Kurdish separatists who straddle the border regions of Turkey and Iraq and have engaged in a rebellion against the Turkish government for decades. Mr. Erdogan is also eager to check Iran’s growing influence in the region and to be seen as a defender of Sunni Arabs and Turkmen, who live in Mosul and the surrounding area.