ERBIL, Iraq — The city of Tal Afar, a former Ottoman outpost not far from Mosul that has a mostly ethnic Turkmen population and has been home to a corps of Islamic State leaders, on Saturday became the focus of a growing struggle between Turkey and Iran for influence in northern Iraq.
That is because Iraq’s Shiite militias, some of which receive support from Iran, began on Saturday to move west of Mosul, a trajectory that would essentially cut off Islamic State fighters in the city from their bases in Syria. The Shiite militias’ move toward Tal Afar could also draw Turkey deeper into the already complex battlefield around Mosul.
As the two-week-old campaign to reclaim Mosul, Iraq’s second largest city, from the Islamic State grinds on in outlying villages, the role of the Shiite militias, controversial because of their history of abuse toward the Sunni population, was part of a delicate set of negotiations involving the Iraqi government and the American-led coalition. Iraq’s prime minister, Haider al-Abadi, agreed to allow the militias a secondary role of sealing off the desert areas west of Mosul, but not entering the city itself.
That seemed to placate the Americans as well as Sunni leaders, especially because the militias, known as the Hashd al-Shaabi, or Popular Mobilization Units, could prove useful in catching Islamic State fighters trying to flee Mosul, as well as any reinforcements the terrorist group might try to send in from Raqqa, its de facto capital in Syria.
The militias, on paper at least, are under the control of the Iraqi government, but many of the most powerful ones answer to Iran and were accused of atrocities during Iraq’s sectarian civil war about a decade ago. But the fight against the Islamic State has given them new legitimacy and political power, even though human rights groups have accused them of revenge attacks against Sunnis during previous battles against the terrorist group.
“The Hashd will get the desert,” Staff Gen. Wathiq al Hamdani, the commander of Mosul’s police force, whose men will secure the city once the army and counterterrorism forces retake it, said in an interview on Saturday. “And it’s a very difficult axis. We have no problem with that, as long as they stay away from the civilians.”
In announcing the offensive by the militias, Ahmed al-Assadi, a militia spokesman, said, “The wounded city of Tal Afar and other areas are within our duties, and will be liberated by our sacred arms and rifles.”
The role of the militias has alarmed Turkey, which has stationed troops in Bashiqa, a town north of Mosul, to train Kurdish and Sunni Arab fighters. It did so without the approval of Baghdad’s Shiite-led government, which has argued that the troop deployment was a violation of the country’s sovereignty. Tensions have run high in recent weeks, with the Turkish president, Recep Tayyip Erdogan, insisting that Turkey has historical claims in the region dating from the Ottoman Empire.
Turkey, with its military deployment in Iraq, has sought to counter the influence of Iran and its militias. The competition for influence in northern Iraq between Turkey, a Sunni power, and Iran, the region’s most powerful Shiite nation, is part of the broader sectarian struggle tearing apart the Middle East.
At least for now, the struggle will be focused on Tal Afar, whose Turkmen population shares a lineage with Turkey, and on the question of whether Turkey will make a move once the militias move on the city. The sectarian divide also cuts through Tal Afar: While Sunnis are there now, before it was taken over by the Islamic State the city was home to a large number of Shiite Turkmen, whom Iran wants to protect and help return to the city.
Turkey’s insistence on a role in the campaign for Mosul, which the United States has objected to unless the Iraqi government agrees, has also deepened sectarian tensions within Iraq. Shiite protesters have converged on the Turkish Embassy in Baghdad, and Iraqi leaders, including Mr. Abadi, have suggested that the two countries could be on a path to military confrontation.
Many Shiites have been taken aback by Turkey’s stance, looking through the lens of history to the Ottoman times when Turkey elevated a Sunni elite to govern the Shiite majority.
“No one has any right to deny any Iraqi the honor of liberating his land,” Ammar al-Hakim, a prominent Shiite religious and political leader, said this past week, in reference to Turkey’s opposition to the Shiite militias.
Mevlut Cavusoglu, Turkey’s foreign minister, has said Turkey will take all necessary measures if it sees a threat emerge to the Sunni Turkmen in Tal Afar after the militias push out the Islamic State, also known as ISIS, ISIL or Daesh.
“Fighting Daesh is necessary,” he said. “But the process after Daesh must be planned carefully. We will not forsake the Turkmens living there. Ethnic and sectarian balances must be taken into account in Mosul and Tal Afar.”