One thousand American troops are leaving northeastern Syria after President Donald Trump decided to pull them out earlier this month.

Earlier this week US Defense Secretary Mark Esper said they would be redeployed to Iraq, where they could keep an eye on oil fields and monitor activity of the Islamic State terrorist group. Hours later, however, Iraq said they were not allowed to.

In an emergency meeting on Wednesday, Esper and Iraq's defense minister agreed to allow the US troops to stay in Iraq for four weeks before going elsewhere, the Associated Press reported.

It was not clear where the troops would go next.

Visit Business Insider's homepage for more stories.

The 1,000 US troops leaving Syria will be allowed to stay in Iraq for at most four weeks, Iraq's defense minister said Wednesday, in an embarrassing rebuff to President Donald Trump's plans for withdrawing from Syria.

Najah al-Shammari's comments to the Associated Press came shortly after his meeting with US Defense Secretary Mark Esper, who went to Baghdad to negotiate the redeployment of US troops in Iraq after they withdrew from Syria.

The emergency meeting came after Esper announced on Monday that the American troops would be stationed along the Iraq-Syria border.

The announcement was seemingly made without bringing Iraq on board first, as the Iraqi government said hours later that the US had not secured permission to do so.

Esper said at the time that US troops would help secure oil fields and monitor activity of the Islamic State terrorist group from Iraq.

Trump has repeatedly claimed that the US has already defeated the Islamic State, also known as ISIS, but the group's militants killed two members of the Iraqi security forces and attacked an oil field in the country just this week.

Read more: Trump's plans for pulling out of Syria were embarrassingly disrupted by Iraq, which says the US isn't allowed to redeploy on its soil

Esper and al-Shammari at their meeting in Baghdad on Wednesday. Hadi Mizban/AP

Al-Shammari on Wednesday said he and Esper agreed that American troops leaving Syria would simply be "transiting" through Iraq before moving on to Kuwait, Qatar, or home to the US, the AP reported.

Al-Shammari added that this transition would take place "within a time frame not exceeding four weeks," as cited by the AP.

It was not clear where the troops would be deployed next. The US Department of Defense has not responded to Business Insider's request for confirmation on Esper and al-Shammari's discussions.

A US military convoy leaving Syria near the town of Tel Tamr on Sunday. AP

Trump has said one of his reasons for withdrawing from northeastern Syria is to end so-called forever wars in the Middle East and bring troops home. Deploying them to Iraq would not fulfill this pledge.

Earlier Wednesday, Esper said the US had no plans to leave troops in Iraq "interminably," the AP reported. He has also met with the country's prime minister, Adel Abdul Mahdi.

The US has more than 5,000 troops in Iraq, but it has attempted to keep the numbers low over political sensitivities after the US occupation during the 2003 war, the AP reported.

President Donald Trump at a hangar rally at Al Asad Air Base in Iraq in December. AP Photo/Andrew Harnik

Esper's meetings in Iraq came a day after the Turkish and Syrian governments struck a deal to expand their control and minimize Kurdish territory in northeastern Syria. Russian troops entered northern Syria on Wednesday to partner with Turkey.

Turkish troops had entered the region to drive out Kurdish forces, with whom the US had partnered to drive out ISIS militants in the region.

Read more: Putin and Erdogan agreed on a 'historic' deal to consolidate power in Syria and humble Kurdish forces. Here are the winners and losers.

The Turkish incursion was essentially approved by Trump, as the troops he ordered withdrawn had acted as a buffer between Turkey and the Kurds.

US troops are making an humiliating exit from Syria, with videos showing their tanks being pelted with rocks and rotten fruit.