ISTANBUL — U.S. troops leaving Syria are only “transiting” through Iraqi territory and will depart within four weeks, the country’s defense minister said Wednesday.

Najah al-Shammari spoke with the Associated Press following a meeting with Defense Secretary Mark T. Esper in Baghdad.

Esper arrived in Iraq for talks amid an apparent disagreement over whether U.S. troops withdrawing from northeastern Syria could now stay in Iraq.

The Pentagon chief said earlier this week that the troops leaving Syria would reposition to western Iraq to continue fighting the Islamic State. But on Tuesday, he appeared to backtrack, saying that American forces would stay only temporarily.

Iraq's military had opposed the move, saying that the newly arrived U.S. forces would have to leave.

"There is no agreement for these forces to stay in Iraq," the statement said.

The dispute added to the turmoil of a rapid U.S. withdrawal from northeast Syria, where American forces had been allied with Kurdish fighters battling the Islamic State.

President Donald Trump had ordered the departure of U.S. troops ahead of a Turkish military offensive targeting the Kurdish-led militias, known as the Syrian Democratic Forces, which Turkey views as a threat to its national security.

The Turkish campaign displaced nearly 180,000 people and prompted the SDF to strike a bargain with the government of Syrian President Bashar Assad, allowing for the return of some pro-Assad forces to areas once under Kurdish control.

The United States helped broker a cease-fire between the SDF and Turkey and its proxies and on Tuesday, Russia and Turkey agreed on a plan to push the Syrian Kurdish fighters from a wide swath of territory just south of Turkey’s border.

Once they were gone, the plan stipulated, Turkey and Russia would begin jointly patrolling the border region. Syrian Kurdish officials did not comment on the initiative.

Turkey's Defense Ministry said Wednesday that the withdrawal of Kurdish fighters following the agreements with the United States and Russia meant that there was "no further need to conduct a new operation."

Turkey’s Foreign Minister Mevlut Cavusoglu told the state-owned Anadolu news agency, however, that Turkish forces would “clear” any “terrorist remnants” from areas now under Turkish control in northeast Syria.

The move by Russia, a key ally of Assad, to negotiate the deal cemented President Vladmir Putin's preeminent role in Syria as U.S. troops depart and America's influence wanes.

The Kremlin said Wednesday that the United States had betrayed and abandoned the Kurds in Syria.

"The United States has been the Kurds' closest ally in recent years . . . [But] in the end, it abandoned the Kurds and, in essence, betrayed them," Kremlin spokesman Dmitry Peskov told Russian news agencies.

Peskov added that if the SDF did not withdraw from the border, Syrian government forces and Russian military police would have to depart, leaving the Kurdish fighters exposed to the Turkish army.

Russia hopes that the deal will lead to Turkey's eventual recognition of Assad's government, analysts said.

Turkish President Recep Tayyip Erdogan, who has been one of Assad's most vocal adversaries during Syria's war, would have to prepare Turkey's public for such recognition, according to Aaron Stein, the director of the Middle East program at the Foreign Policy Research Institute in Philadelphia. "He has already started to do that," Stein added.

Turkey's primary objective "was to push the U.S. out and to break the SDF as the governing entity and as the legitimate political and military actor in the Syrian space. And they did that," he said.

“For Ankara, this is a rational decision. This may take Americans by surprise,” but the final deal was always going to be made with the Russians, he said.