Only weeks before Iraqi troops and their local and international partners start their push to retake the city of Mosul from the Islamic State of Iraq and the Levant (ISIL, also known as ISIS), the leaders of Turkey and Iraq have been caught in a war of words that could derail the Mosul liberation efforts.

“You are not my interlocutor. You are not at my level. You are not my equivalent. You are not of the same quality as me,” said Turkish President Recep Tayyip Erdogan on Tuesday, in response to a demand from Iraqi Prime Minister Haider al-Abadi that Turkey withdraw its troops from Iraq.

“Your screaming and shouting in Iraq is of no importance to us,” he said in a speech to Muslim religious leaders from the Balkans and Central Asia in Istanbul. “You should know that we will go our own way.”

Mosul, home to up to 1.5 million people, has been the headquarters of ISIL’s self-declared caliphate in northern Iraq since 2014. The battle for the city, expected later this month, is likely to shape the post-ISIL Iraq.

READ MORE: Messages from ISIL territory ask forgiveness for murder

Mosul is a historically Sunni city and any attempt to change its demographic composition would be a direct threat to Turkey's security. Ali Faik Demir, Istanbul's Galatasaray University

Erdogan also said that Turkey is determined to participate in the operation to retake Mosul from ISIL, with or without Baghdad’s approval. Turkish media later reported that Turkey is planning to participate in the Mosul operation with an invitation from the president of the Kurdistan Regional Government, Masoud Barzani.

Turkey’s parliament voted two weeks ago to extend the deployment of an estimated 2,000 troops across northern Iraq by a year to combat “terrorist organisations”. Around 500 of these troops are stationed in the Bashiqa camp in northern Iraq, training local fighters who will join the battle to recapture Mosul.

Iraq condemned what it called a “Turkish incursion”, and Abadi warned that Turkey risked “triggering a regional war”.

Abadi’s government requested an emergency United Nations Security Council meeting to discuss the issue, and both countries summoned each other’s ambassadors in a mounting diplomatic standoff. “It is hard to take Baghdad’s threats seriously,” Ali Faik Demir, an expert on Turkish foreign policy from Istanbul’s Galatasaray University, told Al Jazeera.

“A country that cannot protect its territorial integrity and eliminate terrorist elements within itself cannot threaten a neighbour for protecting its own interests. Especially when that neighbour was invited in to the country by Mosul’s former governor to train Sunni militias who are preparing to fight ISIL.”

According to analysts the legitimacy of the government in Baghdad is slowly eroding amid sectarian tensions, foreign interventions and the ISIL occupation. Abadi, say analysts, is trying to use Turkey’s presence in Northern Iraq to fuel a new brand of Iraqi nationalism to keep at least certain parts of the country intact in the post-ISIL era.

“Baghdad knows that it cannot stand up to Iran or the US,” Metin Gurcan, a security analyst and former adviser to the Turkish military, told Al Jazeera. “But it feels that it can use Turkey as a new ‘other’, against which it can build a new, primarily Shia national identity and band at least 60 percent of the country’s population together.”

Turkey is concerned that once ISIL fighters are pushed out of Mosul, the government in Baghdad will make it difficult for Sunni residents of the city to live there. Erdogan previously said that Mosul, which was seized by ISIL two years ago, belongs to “its Sunni residents”.

After Mosul is recaptured, Erdogan added, “only Sunni Arabs, Turkmen and Sunni Kurds should remain there”. His comments prompted the government-backed Shia militias, known as the Hashd al-Shaabi (Popular Mobilisation Forces), to issue a statement condemning Erdogan’s “racist proposal to change Mosul’s demographics”.

But analysts believe that Turkey’s concerns about the future of Mosul should not be interpreted as an attempt to reshape a sovereign country’s demographic make-up. “We have to remember Iraq’s current borders were drawn in the Sykes-Picot agreement,” Demir said.

“Those borders are nothing more than arbitrary lines drawn in the sand by the British. So the situation can only be analysed realistically from a city-centric perspective. Mosul is a historically Sunni city and any attempt to change its demographic composition would be a direct threat to Turkey’s security,” he said.

According to Iraqi analysts, Turkish military presence in Bashiqa represents “a clear violation of national sovereignty. Baghdad views the Turkish forces as an occupation force because the troops were sent to Bashiqa with no prior coordination – or agreement – with the Iraqi government,” said Wathiq al-Hashimi, head of the Baghdad-based Iraqi group for strategic studies, an Iraqi think-tank. Al-Hashimi added that Turkey wanted to “control Mosul in order to create a buffer zone that will allow it to target PKK fighters”.

Analysts emphasised that Turkey’s uneasiness about the prospect of having sectarian militias help Iraqi army in the Mosul liberation operation should not be dismissed simply as a desire to protect fellow Sunnis in the region. “If [these forces] push into Mosul, where will the Sunni residents of the city go?” asked Demir. “Of course they cannot go to Syria, so they will move north, into Turkey. “

Turkey is already hosting 2.7 million refugees, he said. “Turkey simply cannot absorb another wave of refugees, so the Turkish government and military need to take necessary precautions to make sure residents of Mosul can stay in Mosul after ISIL is ousted from their city.”

READ MORE: Meet the fighters preparing to retake Mosul from ISIL

The US recently told Turkey to respect the Iraqi government’s wishes regarding its military presence in the country. “All of Iraq’s neighbours need to respect Iraq’s sovereignty and territorial integrity,” State Department spokesman John Kirby said on Tuesday. “We call on both governments to focus on their common enemy, our common enemy, which is Daesh,” Kirby said, referring to ISIL by an Arabic acronym.

But analysts believe that US’ position on this issue is nothing more than a piece of rhetoric. “All actors in the region, including the US, are currently trying to reposition themselves for the post-ISIL setting,” Gurcan said.

“They may talk about the importance of Iraq’s sovereignty and territorial integrity, but none of the actors are keen to go back to the status quo before the emergence of ISIL. They know that this is not possible in practice.”

The US believes that Turkey is trying to create a Sunni power-house around Mosul and it is not necessarily against this idea, said Demir.

“A Sunni entity in northern Iraq may reduce Iran’s influence in this region, and the US would appreciate that,” he said. “But Ankara has been trying to exclude Washington from this game. It has been trying to act as an independent actor by aligning itself with sub-state actors, and that is the source of the US’ frustration with Turkey,” Gurcan explained.

“There is no right and wrong in northern Iraq at the moment and what happens to Mosul may start a domino reaction that can change all regional maps. All we can do is to wait and see.”

Al-Hashimi said that the Iraqi government should keep self-restraint and not get involved in any military activity against the Turkish troops in Bashiqa. “The Bashiqa military camp is situated in a crossfire once the battle [for Mosul] starts. And here, the Iraqi government has to inform Ankara, and the whole world, that Baghdad can’t be held responsible for any possible targeting of the Turkish troops.”