He did not elaborate on how Turkey planned to join the Mosul operation despite Baghdad’s objections. Washington also continues to say that the presence of foreign troops in Iraq is subject to Baghdad’s approval.

“It’s logical for a safe zone to be under the KRG’s control. Barzani and the KRG control that region. We will do it with the real owner of the region, Massoud Barzani. The KRG does not think differently with Turkey on this,” Yildirim said.

Yildirim also said Turkey and the Kurdistan Regional Government (KRG), headed by Massoud Barzani, were working on a safe zone in northern Iraq.

Prime Minister Binali Yildirim reiterated Turkey’s position over the weekend in a TV interview. Yildirim said plans for Turkey’s participation in the Mosul operation were ready, and he underlined that Turkey would also be at the negotiating table determining the future of the city.

Turkey is not prepared to take a step back in its spat with Baghdad. The mood in Ankara remains defiant despite Baghdad’s insistence that Turkey not be allowed to participate in the Mosul operation and demands that Turkish troops in Bashiqa near Mosul be withdrawn.

Deputy Prime Minister Numan Kurtulmus has indicated that the Turkish troops in Bashiqa are there on the request of the KRG and were sent to train peshmerga and other fighters against the Islamic State (IS).

It is also not clear how Ankara plans to be at the negotiating table if Baghdad opposes this. Most intriguing, however, was Yildirim’s remarks about a safe zone in northern Iraq, which, judging by his words, will go ahead whether Baghdad likes it or not.

Yildirim’s remarks suggest that one aim of this zone will be to shelter refugees from Mosul and elsewhere in Iraq. Turkish officials note that when Mosul fell to IS in 2014, the majority of the mostly Sunni inhabitants fleeing the city went to areas under KRG control, rather than south.

Turkey also wants this zone to prevent the outlawed Kurdistan Workers Party (PKK) and its affiliates from establishing themselves in and around the town of Sinjar, the way they have done in the Qandil Mountains of northern Iraq.

There has been no confirmation or denial about this zone from the KRG. Barzani clearly does not want to endanger ties with Turkey. His crisis of confidence with Baghdad lingers, despite moves by the sides prior to the launching of the Mosul operation to reconcile differences.

The debate regarding Turkey’s military presence and role in Mosul appears set to continue, but what is becoming clearer is that Barzani is Ankara’s principal ally in Iraq. He not only provides a foothold for the Turkish military presence there, but he also provides a degree of legitimacy for it.

Barzani’s support to Ankara over Bashiqa was seen recently when his Kurdistan Democratic Party (KDP) refused to back a resolution by anti-Turkish parties in the Kurdistan Regional parliament calling on Turkey to withdraw its forces from Iraq.

Barzani also does not want to endanger the giant energy deals he concluded with Ankara in recent years for exporting northern Iraqi oil via Turkey. Baghdad says these deals are illegal.

Turkish nationalist quarters, though, are not keen about the ties between Ankara and Erbil. They suspect the aim of the Iraqi Kurds is to ultimately establish an independent Kurdistan. They are also displeased with the peshmerga presence in the forefront of the fight for Mosul.

It is also evident, however, that Barzani does not want to appear to be Turkey’s Trojan horse in Iraq, especially when developments are forcing him to maintain a delicate balance between Ankara, Baghdad and Tehran, the three capitals that are the most relevant for the KRG.

When it comes to the question of Turkey’s participation in the Mosul operation, Barzani is more circumspect. He says Ankara and Baghdad have to agree for this to happen.

Al Monitor’s Ali Tahir pointed out that there are also increasing voices in KRG-controlled areas calling for better ties with Baghdad. Barzani himself reportedly assured Baghdad recently that they are not looking to secede and are only seeking regional autonomy.

Recently Barzani also lauded the fact that peshmerga and Iraqi soldiers were shedding blood together for the first time in order to liberate Mosul.

Ankara is obviously watching these overtures between Erbil and Baghdad closely. Abdulgani Ali Yahya, a Kurdish journalist in Erbil close to the KDP, nevertheless believes that Turkish-KRG ties are not in any danger. He says that the current reconciliation between Erbil and Baghdad is only a matter of convenience.

“The problems between Erbil and Baghdad can’t be solved with one or two meetings. Under pressure from the United States, Baghdad is trying to gain time. Barzani sees this but does not want to undermine the basis of negotiation,” Yahya said in an interview with Al Jazeera.

He argued that trouble between Erbil and Baghdad will re-emerge after the Mosul operation is concluded. Yahya also said Erbil’s ultimate aim was to attach large swathes of Ninevah province, where Mosul is located, to the KRG, on the basis of a referendum to be held under Article 140 of the Iraqi Constitution.

This kind of remark sounds a warning for Turkish nationalists, who are already angry that oil-rich Kirkuk — which they believe belongs to Turkey, like Mosul, by right — is under KRG control today.

Some also argue that the ruling Justice and Development Party’s pro-Sunni leanings will make it more palatable for Ankara if Mosul were run by the predominantly Sunni KDP rather than by mainly Shiite Baghdad.

“Does anyone today talk about Kirkuk having gone to Barzani? In a few years they will also forget Mosul,” argued Gurbuz Evren, a former Turkish academic and TV presenter who comments on political issues.

Retired Maj. Gen. Armagan Kuloglu also warns about plans for a “Greater Kurdistan” and says this is why Turkey must take part in the Mosul operation. Maintaining that the peshmerga also do not want Turkey’s participation in this operation, he reasons that the KRG's aim is to clear Mosul of IS with US support and expand its sovereignty over the region, as it did in Kirkuk.

“We have to act knowing that the game in our region is to establish a Greater Kurdistan. This is the aim of Barzani and the Kurdish elements in Syria, including the Democratic Union Party, as well as global powers that support them, starting with the US,” Kuloglu said in an opinion piece summing up the view of nationalists.

However, the close ties that have developed over the years between Ankara and Erbil suggest more than an “occasional relationship of convenience” and point, to the annoyance of nationalists, to a pragmatic relationship with a long-term perspective.

Middle East politics, however, sits on slippery ground. With political tensions in Turkey and developments in Iraq and Syria, ties between Ankara and Erbil could turn sour overnight, depending on how the wind blows.

For now, though, realism appears to be setting the rules of these ties.