Iraqi troops guard a checkpoint near the village of Awsaja, Iraq, as smoke from fires lit by Islamic State militants at oil wells and a sulfur plant fills the air on Oct. 22. (Adam Schreck/AP)

BAGHDAD — Iraq’s prime minister on Saturday rejected the possibility of Turkish involvement in the current campaign to liberate Mosul from the Islamic State, just a day after Defense Secretary Ashton B. Carter announced that he had reached an “agreement in principle” with Turkish officials that would allow Turkey to participate in the battle.

In a meeting with Carter at his palace, Iraqi Prime Minister Haider al-Abadi stressed that it was important to have good relations with his Turkish neighbor but that their troops would not be welcome in Mosul.

“The Mosul battle is an Iraqi battle, and the ones who are conducting it are Iraqis,” Abadi said. “We don’t have any problems. [If help is needed,] we will ask for it from Turkey or from other regional countries,” Abadi said.

On Friday, Carter met in Ankara with Turkish President Recep Tayyip Erdogan, Prime Minister Benali Yildirim and Defense Minister Fikri Isik to discuss Turkey’s role in the fight against the Islamic State, particularly in Mosul.

Abadi’s rejection of Turkish involvement in the battle for Mosul comes in the middle of heightened tensions between the two countries, as Iraq has put pressure on Turkey to remove its contingent of roughly 500 troops from the northern part of the country. Iraqi officials say the Turkish troops, who have been training Kurdish and Arab militias at a base there since December, are in the country without permission.

Despite the setback in Turkish-Iraqi cooperation, Carter said during a news conference following his meeting with Abadi that he believes the United States could still play a constructive role between the two countries.

“We all need to stay focused on the fight against ISIL,” Carter said, using another acronym for the Islamic State.

With or without Turkish assistance, the liberation of Mosul — Iraq’s second-largest city and the Islamic State’s last stronghold in the country — is well underway. Carter’s visit here Saturday comes almost a week after the start of the campaign, following months of operations in the countryside surrounding the city.

Carter congratulated Abadi and his forces for starting the campaign in Mosul as well as the continued unity between the myriad forces on the battlefield, many of which have religious and ideological differences between one another. Carter also reinforced the United States’ commitment to the campaign.

About 500 U.S. forces are spread across the Mosul battlefield, manning artillery, acting as advisers to Iraqi and Kurdish forces and helping call in airstrikes. U.S. Special Operations forces are also playing a role, operating alongside the Kurdish peshmerga and Iraqi Special Operations forces. Overhead, U.S. and coalition aircraft, including heavy bombers and helicopter gunships are on-call to provide support for the advancing Iraqi forces.

Mosul, which fell to the Islamic State more than two years ago, has since been reinforced with minefields, tunnel systems and an array of booby traps. It is thought to be defended by more than 5,000 fighters, a thousand of which are probably foreign fighters, expected to fight to the death.

Lt. Gen. Stephen Townsend, the commander of the U.S.-led campaign in the country, said during the news conference that the Islamic State’s resistance outside the city has been determined but expected.

Though early stages of the battle have seen pockets of sporadic fighting that include sniper fire, roadside bombs and antitank guided missiles, the tens of thousands of Iraqi, Kurdish peshmerga and militia forces have steadily advanced across swaths of desert and into small hamlets as they draw within miles of the city. Despite the progress, the forces are probably days, if not weeks, from the city itself. There, U.S. military officials said, the fighting will be the heaviest as that is where the Islamic State has focused the majority of its defenses.

According to Col. John Dorrian, the U.S.-led coalition’s spokesman, Kurdish peshmerga forces advancing from the east and the north have reached their limit of advance, roughly 20 kilometers outside of the city. Soon on those fronts, Iraqi forces will take the lead and start pushing into the city. In the southeast, Iraqi Special Operations units entered a number of small villages, encountering stiff resistance in the form of bomb-laden suicide vehicles and mortar fire.

While Iraqi and Kurdish forces have taken the brunt of casualties, a U.S. Navy bomb disposal technician — Chief Petty Officer Jason C. Finan — was killed Thursday when his vehicle struck a roadside bomb.

U.S. troops have also been forced to don gas masks after Islamic State fighters set fire to the Mishraq sulfur mine north of Mosul earlier this week, according to U.S. defense officials in Baghdad who spoke on the condition of anonymity to discuss the developing situation. In recent days, shifting winds began blowing the noxious fumes over the troops who are stationed at a forward staging base near the near city.

Although much of the mine was burned during the 2003 invasion of Iraq, about 10 percent of the sulfur still remains. Iraqi forces estimate it will be two to three days before the fires at the mine are completely extinguished.