Turkey and Iran summoned each other's ambassadors on Sunday, Turkish and Iranian state media reported, escalating a rumbling row over Turkey's presence in Iraq.
Iran and Turkey are rivals in several parts of the Middle East and Central Asia but both have carried out operations against Kurdish militants in northern Iraq.
Earlier this month, Turkey accused Kurdish militants of killing 12 Turks and an Iraqi who were being held hostage in northern Iraq,
The incident prompted Iranian envoy to Baghdad Iraj Masjedi to warn that Turkish forces should not "pose a threat or violate Iraqi soil".
"We do not accept at all, be it Turkey or any other country, to intervene in Iraq militarily or advance or have a military presence in Iraq," Masjedi was quoted as saying in an interview broadcast on Saturday.
Turkey's Baghdad envoy Fatih Yildiz quickly hit back, writing on Twitter that Iran's ambassador was "the last person to lecture Turkey" about respecting Iraq's borders.
Turkish foreign ministry officials summoned Iranian ambassador Mohammad Farazmand and told him Turkey expected Iran to be on its side in the "fight against terrorism", Turkey's state news agency Anadolu said.
Ministry officials also told the ambassador Turkey "strongly rejected" the envoy's comments, insisting that Ankara always informed relevant parties including Baghdad of its plans to target militants.
Turkey's envoy to Tehran was also summoned on Sunday by the Iranian foreign ministry over comments made by Turkish Interior Minister Suleyman Soylu on Kurdish militants' presence in Iran, Iran's state news agency IRNA reported.
Soylu last weekend said there were "525 terrorists" in Iran.
Iranian officials emphasised his remarks were unacceptable and ran contrary to the two countries' cooperation efforts, IRNA said.
The Iranians also insisted to the Turkish envoy Derya Ors that Tehran was serious in its determination to fight terrorism, and rejected Yildiz's "unjustified" remarks.
Turkey has launched multiple air strikes targeting the Kurdistan Workers' Party (PKK) bases in northern Iraq including the areas of Kandil and Sinjar.
The PKK, which has fought an insurgency against the Turkish state since 1984, is blacklisted as a terrorist organisation by Ankara and its Western allies.
Turkey bombed a mountainous region close to Sinjar last month and Turkish President Recep Tayyip Erdogan has warned Ankara could launch military action to get rid of "terrorists" in the area.
But the Iranian ambassador to Baghdad hit out at Turkey's plans.
"What has Sinjar got to do with Turkey," he asked. "Iraqis themselves must resolve this issue."