By Tulay Karadeniz and Tuvan Gumrukcu
ANKARA (Reuters) - President Tayyip Erdogan warned Iraq's prime minister he should "know his limits" after he criticized Turkey's military presence there and said the Turkish army, shaken by a failed coup bid, had not lost so much standing as to take orders from him.
NATO member Turkey shares a 1,200 km (750-mile) border with Syria and Iraq and faces threats from Islamic State militants in both. But it is concerned that international efforts to destroy radical Islamists will leave new dangers in their wake.
The Turkish army, its senior ranks purged following a failed military attempt to overthrow Erdogan in July, launched an incursion into Syria in August to push back Islamic State and prevent U.S.-backed Kurdish militia fighters from seizing territory. Ankara is wary of Washington's support for what it sees as a hostile Syrian Kurdish force.
Erdogan suggested Turkey could take a similar attitude in Iraq, where expectations are growing of an assault to drive Islamic State out of the northern city of Mosul.
"We will approach the operation in Iraq, the operation that will be in Mosul soon, with the same attitude," Erdogan told a meeting of Islamic leaders in Istanbul in televised comments.
"Turkey cannot intervene against the threats right next to it? We will never accept this ... We don’t need permission for this, and we don’t plan on getting it."
The main point of contention is the presence of Turkish troops in Iraq, mainly at the Bashiqa camp in the north of the country, training Sunni Muslim and Kurdish Peshmerga units which Turkey wants to take part in the battle for Mosul.
However, the Shi'ite-led government in Baghdad is keen that its forces be in the forefront of the offensive on the city, the largest under Islamic State control.
The United States said on Tuesday any foreign forces in Iraq should be there with the approval of the Baghdad government and under the umbrella of the U.S.-led coalition fighting Islamic State militants.
"The Turkish forces that are deployed in Iraq are not there as part of the international coalition and the situation in Bashiqa is a matter for the governments of Iraq and Turkey to resolve," U.S. State Department spokesman John Kirby told a daily press briefing.
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 organizations" - a wording broad enough to refer to Kurdish militants as well as Islamic State.
Iraq condemned the vote, and Prime Minister Haider al-Abadi warned Turkey risked triggering a regional war. His government has requested an emergency United Nations Security Council meeting to discuss the issue, and both countries have summoned each other's ambassadors in a mounting diplomatic stand-off.
"The Iraqi prime minister is insulting me, first know your limits," Erdogan said.
"Iraq had certain requests from us regarding Bashiqa, and now they are telling us to leave. But the Turkish army has not lost so much standing as to take orders from you."
Turkey argues that involving Shi'ite militias in a drive to expel Islamic State from Mosul will not bring peace.
"If you try to change the demographic structure in Mosul, you will ignite the fire for a major sectarian war," Turkish Prime Minister Binali Yildirim told members of his ruling AK Party at a meeting in parliament.
Foreign Minister Mevlut Cavusoglu said Turkey could play the same role in the Mosul offensive or any campaign to take Raqqa, Islamic State's stronghold in Syria, as it did with its August incursion into the Syria, when it sent in tanks and fighter jets in support of Syrian rebels fighting the Islamist radicals.
"Turkey can give the support it gave Jarablus to Raqqa or Mosul as well," Cavusoglu said in an interview on Turkey's A-Haber television. "Turkey is ready for any kind of support to cleanse Syria and Iraq of Daesh," he said, using an Arabic term for Islamic State.
(Additional reporting by Ece Toksabay in Ankara and Ayla Jean Yackley in Istanbul, and Eric Beech in Washington; Writing by Nick Tattersall; editing by Ralph Boulton, Grant McCool)