US President Donald Trump (C) watching in the Situation Room as US Special Operations forces close in on ISIS leader Abu Bakr al-Baghdadi - AFP

President Donald Trump’s abrupt order to withdraw US troops from Syria disrupted the planning of the raid on Isil leader Abu Bakr al-Baghdadi’s compound, it has emerged.

Mr Trump knew the intelligence services were zeroing in on the location for Baghdadi when he ordered American troops to retreat from northern Syria earlier this month, US officials told the New York Times.

They said they had warned the president that finding the elusive Isil chief should be the US’s top priority and that any major change on the ground could jeopardise it.

“The raid occurred largely in spite of, and not because of, Mr Trump’s actions,” they said.

The Telegraph understands that Saturday’s risky mission had to be rushed before the US lost the ability to control special forces in the area and air space over north-east Syria.

View photos President Donald Trump was booed as he attended a World Series game at Nationals Park on Sunday night Credit: Tommy Gilligan-USA TODAY Sports More

The planning for the raid on the compound Baghdadi had been staying took several months.

A senior Iraqi official told the Telegraph it shared in September information with the US that its national intelligence service obtained from interviews with captured members of Baghdadi’s inner circle, including his courier and the courier’s wife.

They led him to the terror chief’s location in Idlib, rebel-held north-west Syria a few miles from the Turkish border.

The operation was full of dangers. The US had to “deconflict” with Russia and Turkey, which both operate in the crowded skies above Syria.

The compound was deep within territory controlled by al-Qaeda-aligned rebels. The officials said the mission was called off at least twice at the last minute.

View photos An aerial shot taken of the site that was hit by helicopter gunfire during a raid on Baghdadi's location near the northwestern Syrian village of Barisha in the Idlib province Credit: AFP More

The plan was coming together just as the US’s 1,000 troops were being pulled out of the country and sat waiting for instructions in neighbouring Iraq. Mr Trump's decision to pull out left the US's main partner against Isil, the Kurdish-led Syrian Democratic Forces (SDF) to fight alone.

Realising belatedly that the decision had forfeited all US leverage, Mr Trump then ordered several hundred of them to return last week.

According to war monitor, Syrian Observatory for Human Rights 500 have crossed back over the border in recent days.

Brett McGurk, the former presidential envoy to the anti-Isil coalition who resigned in December over Mr Trump’s decision to drawdown troops, said the operation “spoke to what we have forfeited with the sudden US retreat across its northeast this month."

Story continues