IRBIL, Iraq — Iraq's Shiite militias said Saturday that they had joined the operation to recapture the Islamic State-held city of Mosul, a move that could whip up sectarian and regional tensions in an already complex battle.

Militia leaders said they launched an offensive toward the town of Tal Afar, about 40 miles west of Mosul. More than 10,000 fighters are participating, they said.

Containing the role of powerful Shiite militias presents a challenge for Prime Minister Haider al-Abadi as Iraqi troops push toward the largely Sunni city of Mosul in the country's largest military operation since the 2003 U.S.-led invasion. In past battles against ISIS, the Iraqi militias have been accused of kidnappings and executions.

After more than two years of Mosul being under the militants' rule, the battle is seen as a chance to reset relations between the city's Sunnis and the Shiite-led national government, which had plunged so low by 2014 that some of the city's residents welcomed the militants. How the advancing forces deal with the local population is key to rebuilding trust.

The offensive to retake Iraq's second-largest city has mostly been limited to fighting in towns and villages far from the outskirts of Mosul, and the entire operation is expected to take weeks, if not months. The offensive was launched by Iraqi forces on Oct. 17.

Shiite militia leaders have agreed not to enter Mosul itself for now. But Tal Afar, where the militias are now focused, is itself a dangerous flash point, analysts have said. The town where Sunnis and Shiites once mixed has the potential to be the scene of revenge killings.

The presence of Iranian-backed militias could also give Turkey, which has insisted on a role in the Mosul operation despite furious protestations from Baghdad, an excuse to deepen its involvement, raising the specter of more conflagration.

Turkey has said it has a duty to protect the people of Tal Afar, who are ethnic Turkmen, but it also has a strategic interest in countering Iranian influence in Iraq.

Any Turkish forces in Iraq will be dealt with "as the enemy," said Jawad al-Tleibawi, a spokesman for the Asaib Ahl al-Haq Shiite militia. "We already have plans to confront any intervention by them," he said. Tleibawi said Shiite militias also planned to retake Hatra and Baaj, putting them in the vicinity of Kurdish peshmerga forces, who have clashed with them in the past.

U.S. diplomats last week failed to broker an agreement between Turkey and Iraq.

Many of Iraq's Shiite militias formed after 2003 to fight U.S. troops, but they have grown since 2014, when they stepped in to fill security gaps as the Iraqi army collapsed in parts of the country.

Due in part to sectarian concerns, the militias have been gradually sidelined during operations to retake largely Sunni urban centers from ISIS militants, but they have fought on the outskirts of those battles.

When Iraqi forces retook the western city of Fallujah this year, militias were accused by rights groups and local government officials of kidnapping hundreds of men as they fled the city.