BAGHDAD - U.S. Defense Secretary Mark Esper arrived in Baghdad on Wednesday, where he is likely to face questions about how long U.S. troops withdrawing from northeast Syria will stay in Iraq.

The Iraq military said on Tuesday that U.S. forces crossing into Iraq as part of a pull-out from Syria do not have permission to stay and can only be there in transit.

While Esper initially told reporters the troops withdrawing from Syria would go to western Iraq to fight Islamic State and "help defend Iraq," he said on Tuesday that Washington aimed to eventually bring the troops back to the United States.

Esper is expected to meet his Iraqi counterpart as well as Prime Minister Adel Abdul Mahdi and discuss the U.S. troop drawdown from Syria and the role Iraq will play in it.

"Our key priority with Iraq is encouraging the continued secure, stable, independent Iraq," a senior U.S. defense official said.

Esper's trip also follows an agreement on Tuesday between Ankara and Moscow that Syrian and Russian forces will deploy in northeast Syria to remove Kurdish fighters and their weapons from the border with Turkey.

Hours after that deal was announced, the Turkish defence ministry said the United States had told Turkey the withdrawal of Kurdish militants was complete from the "safe zone" Ankara demands in northern Syria.

The Russia-Turkey agreement struck in the Black Sea resort of Sochi endorses the return of Syrian President Bashar al-Assad's forces to the border alongside Russian troops, replacing the Americans who had patrolled the region for years with their Kurdish allies.

President Donald Trump decided earlier this month to withdraw all 1,000 U.S. troops from the region, a move widely criticized as a betrayal of Kurdish allies who had fought for years alongside U.S. forces against Islamic State.

Since then, the Pentagon has said the Trump administration is considering keeping some troops in northeastern Syria to help ensure Islamic State and others do not profit from oil fields in the region.

Any decision to keep additional U.S. troops in Iraq is likely to be heavily scrutinized in a country where Iran has been steadily amassing influence.

Iraq is in the midst of a political crisis.

Protests over high unemployment, poor public services and corruption erupted on Oct. 1, prompting a violent security crackdown.

Protesters blame graft and infighting among political leaders for failing to improve their lives even in peacetime, two years after Islamic State was declared defeated in Iraq.

"Iraqi politics are in a delicate state. There’s no Iraqi support for the country becoming a principal U.S. garrison in the Middle East," said Jon Alterman, Middle East expert at the Center for Strategic and International Studies.

However, Baghdad did not want to alienate Washington, which has been a key ally in fighting back Islamic State militants over the past five years, Alterman added.

The additional U.S. troops would add to the roughly 5,000 publicly acknowledged American troops already based in the country, training Iraqi forces and helping to ensure Islamic State militants do not make a comeback.

(Reporting by Idrees Ali; Editing by Tom Hogue and Lincoln Feast.) ((ahmed.aboulenein@tr.com; +964 790 191 7021; Reuters Messaging: ahmed.aboulenein.thomsonreuters.com@reuters.net))