The operation to liberate Mosul has launched, and U.S., Iraqi government, Kurdish Peshmerga, Yezidi, Christian and local Sunni forces are on the move. Their effort faces many challenges. One of the most important is the dispute between Ankara and Baghdad over the presence of Turkish troops at Bashiqa northeast of Mosul. Unless addressed quickly, there is danger of a war within a war that could damage the prospects for retaking and stabilizing Mosul.

Baghdad and Ankara agree on the goal of removing ISIS but not on much else. Based on conversations I had during my visit last week to Turkey and Kurdistan, the disagreement has five key elements.

First, the interlinked civil wars in Syria and Iraq are the product of a regional geopolitical struggle in which Turkey and Iran are key players who exploit the ethnic and sectarian fault lines of their neighbors. Despite improved cooperation between Iran and Turkey on bilateral issues — including the role of Kurds in Syria — they compete for influence in Iraq and Syria. From Ankara’s perspective, the disagreement with Baghdad on Turkey’s presence in Bashiqa is not so much between Turkey and Iraq as it is between Turkey and the Shiite-dominated Iran-leaning government in Baghdad. Further, Ankara maintains that the Iraqi government’s legitimacy is eroded by years of civil war and sectarian policies that persecuted Iraq’s Sunnis and Sunni Turkomen and alienated its Kurds.

Second, Ankara is concerned not just about Mosul proper but also about the surrounding area, where Iran would like to establish an outpost at the junction of the Iraqi, Syrian, and Turkish Kurdish regions. Control of this territory would allow Iran to project power—directly or via proxies—on behalf of the Assad regime in Syria. It would also give Iran the ability to harass the Kurdish Regional Government in Iraq. The Turks believe Iran is seeking a land corridor to the Mediterranean shores of Syria and Lebanon for which Mosul would present the shortest route from Iran – an outcome they want to block.

Third, Turkey has historic and cultural ties with Mosul and its Sunni Arab and Sunni Turkomen populations. There is even a sense among Turkish leaders, as expressed by President Erdogan’s chief adviser Ilnur Cevik , that this region, along with northern Syria, should have never been relinquished after the First World War. Key Arab leaders in Mosul have a similar appreciation for shared history and view strong ties with Turkey as a critical element of balance in dealing with the threat of Shiite militias and Iran. Turkey believes that the Sunni Turkoman population of the area is particularly vulnerable and has voiced concerns about possible plans by Iran and sectarian militias to force demographic changes by displacing Sunni Turkoman populations from areas around Mosul such as Tel Afar.

Fourth, Ankara has developed a strategic relationship with the Kurdish Democratic Party, including a commitment to Erbil to help defend it against threats, even those emanating from Baghdad. Ankara has maintained a military presence in the Kurdish region — though not in Bashiqa — for many years.

Fifth, Turkey wants to prevent the Kurdistan Workers Party (PKK) — which has been engaged in an insurgency against the Turkish state for four decades — from expanding its presence in northern Iraq. The PKK had established a presence in the Sinjar area after it helped retake the district from ISIS last fall and Turkey opposes its involvement in the Mosul operation.

The United States is caught in the middle of this complex struggle. Given the critical importance of Baghdad in the fight against ISIS, and the desire to assist Abadi and lessen his dependence on Iran, the United States has been partial to Baghdad’s position. Washington regards Turkey's posture as unhelpful and its potential actions as a wild card. The United States has even pressured the Iraqi Kurdish leadership to ask the Turks to withdraw their forces from Bashiqa. This, unsurprisingly, did not succeed.

However, Washington shares Turkey’s concerns with regard to Iranian aspirations and the danger of Shiite militias committing sectarian atrocities in Mosul that could lead to the resurgence of sectarian problems even after ISIS is expelled.

Rather than picking sides in the quarrel between Baghdad and Ankara, the United States should use diplomacy to find an arrangement that facilitates operations against ISIS in Mosul, checkmates Iranian objectives in Mosul (including operations by pro-Iran militias in the city), does not embarrass Abadi or increase his reliance on Iran, and precludes a potential clash between Iraqi and Turkish forces.

Senior Iraqi and Turkish national security officials met in Istanbul a couple of weeks ago and reached an agreement in principle on the use of the Bashiqa base, where Turkey’s forces are located, as a Coalition base, without requiring the Turkish forces to withdraw. The United States should pursue an initiative to implement this idea so that troops from other Coalition members can be based there alongside Turkish troops and Iraqi Sunni Arab volunteers. This would achieve several positive outcomes. It would give the United States leverage against Shiite militias and their movements near Mosul, avoid further worsening relations between Baghdad and Ankara, and avoid a war within war in the Mosul offensive.

Heavy-handed Turkish tactics in defending the continued presence of their troops have complicated the situation. Personal attacks on Abadi and undiplomatic remarks about the Baghdad parliament make him look vulnerable. This is counterproductive as it strengthens the militias’ argument that the government is weak and that they are needed in Mosul to defend Iraq’s territory from foreign interference. Turkey’s imperious attitude has left even some traditional friends of Turkey and anti-Iran politicians, like Ayad Allawi, with no choice but to demand the withdrawal of Turkish troops. Even some Turkomen representatives have criticized Turkey’s approach, arguing that their community will bear the backlash.

Taking quick action to bring Turkish forces in Bashiqa under the Coalition fold would help contain tensions and avoid negatively impacting the operation to liberate Mosul.

Zalmay Khalilzad is the former U.S. Ambassador to Afghanistan, Iraq and the United Nations.

Image Credit: Creative Commons License.