BAGHDAD (AP) — U.S. Defense Secretary Mark Esper arrived in Baghdad on Wednesday as chaos swirled along the Turkey-Syria border and Iraqi leaders chafed over reports that the U.S. may want to increase the number of troops based in Iraq, at least temporarily.

Esper’s meetings Wednesday at the Iraqi Defense Ministry came a day after Iraq’s military said American troops leaving northeastern Syria don’t have permission to stay in Iraq.

The Iraqi statement appeared to contradict Esper, who has said that all U.S. troops leaving Syria will go to western Iraq and that the military would continue to conduct operations against the Islamic State group to prevent its resurgence in the region.

He later added that the troops would be there temporarily until they are able to go home, but no time period has been set. Esper said Wednesday that the U.S. has no plans to leave those troops in Iraq “interminably” and that he plans to talk with Iraqi leaders about the matter.

Meanwhile, Russia and Turkey reached an agreement on Tuesday that would deploy their forces along nearly the entire northeastern border to fill the void left after President Donald Trump’s abrupt withdrawal of U.S. forces from the area, a move that essentially cleared the way for the Turkish invasion earlier this month.

It was unclear Wednesday what that means for U.S. forces.

Trump ordered the bulk of the approximately 1,000 U.S. troops in Syria to withdraw after Turkish President Recep Tayyip Erdogan stated in a phone call that his forces were about to invade Syria to push back Syrian Kurdish fighters whom Ankara considers terrorists.

The pullout largely abandons the Kurdish allies who have fought the Islamic State group alongside U.S. troops for several years. Between 200 and 300 U.S. troops will remain at the southern Syrian outpost of Al-Tanf.

Esper said the troops going into Iraq would have two missions, one to help defend Iraq against a resurgence of Islamic State militants and another to monitor and perform a counter-IS mission.

The U.S. currently has more than 5,000 American forces in Iraq, under an agreement between the two countries. The U.S. pulled its troops out of Iraq in 2011 when combat operations there ended, but they went back in after the Islamic State group began to take over large swaths of the country in 2014.

The number of American forces in Iraq has remained small due to political sensitivities in the country, after years of what some Iraqis consider U.S. occupation during the war that began in 2003. Iraqi leaders may privately condone more U.S. forces to battle IS, but worry if it’s widely known that there will be backlash from the citizens.

U.S. troops in Syria fought for five years alongside Kurdish-led forces in northeast Syria and succeeded in bringing down the rule of IS militants — at the cost of thousands of Kurdish fighters’ lives. Under the new agreement, much of that territory would be handed over to U.S. rivals.

The biggest winners are Turkey and Russia. Turkey would get sole control over areas of the Syrian border captured in its invasion, while Turkish, Russian and Syrian government forces would oversee the rest of the border region. America’s former U.S. allies, the Kurdish fighters, are left hoping Moscow and Damascus will preserve some pieces of the Syrian Kurdish autonomy in the region.