President Donald Trump congratulated US special forces, and himself, this weekend for the military strike in Syria that killed the Islamic State's leader, Abu Bakr al-Baghdadi.

But a more detailed look at the operation suggests the success came in spite of — and not because of — Trump.

The strike wouldn't have been possible without three key factors, all of which Trump has tried to derail: a US troop presence in Syria; the Kurdish allies who were abandoned when Trump withdrew US troops; and the US intelligence community that Trump has spent three years attacking.

Visit Business Insider's homepage for more stories.

This weekend brought one of the biggest victories in America's fight against terrorism in more than five years. President Donald Trump announced that US special forces carried out a military strike in Syria that killed the Islamic State's leader, Abu Bakr al-Baghdadi.

The president and lawmakers lauded the soldiers and military leaders who participated in the operation and praised their bravery. Trump also thanked US adversaries like Russia and Turkey, which he said cleared airspace for US helicopters to make their way into an area near Syria's Idlib province, where al-Baghdadi was holed up.

Al-Baghdadi's death was indeed a massive victory for the United States and its allies. And politically, the news is nothing short of a miracle for the president, giving him some ground to stand on as he battles a brewing impeachment inquiry and allegations that he leveraged US foreign policy in Ukraine for his personal gain.

It's worth noting, though, that the US's operation against al-Baghdadi wouldn't have been possible without three key factors, all of which the president actively tried to undermine throughout his time in office:

The presence of US troops in Syria

The US's Kurdish allies in Syria

The US intelligence community

The al-Baghdadi operation wouldn't have happened if the military hadn't slow-walked Trump's Syria retreat

The Islamic State's leader, Abu Bakr al-Baghdadi, speaking in a video released in April. Reuters

In the weeks leading up to al-Baghdadi's death, Trump made the abrupt decision to withdraw US troops from northeastern Syria, a move that caught Kurdish allies in the area off guard, opened them up to a Turkish assault, and effectively solidified Russia's dominance in the region.

Foreign-policy experts pointed out on Sunday that had the US military not slow-walked Trump's directive to pull troops from the area, the raid against al-Baghdadi wouldn't have been possible.

Read more: Activist video purports to show moment of US raid on al-Baghdadi ISIS compound. Photos show the wreckage left in its wake.

Indeed, the operation happened in spite of — and not because of — the president's actions.

"We must keep in mind that we were able to strike Baghdadi because we had forces in the region," Republican Rep. Michael Waltz, a former Army Green Beret, told The New York Times. "We must keep ISIS from returning by staying on offense."

As Axios reported, al-Baghdadi's death was ironic because it underscored the importance of having US troops in Syria. It highlighted the argument in favor of continued US engagement and why Iraq and other countries were so caught off guard and worried when Trump announced the troop withdrawal.

The Kurds played an integral role even after being abandoned by the US in Syria

Kurdish peshmerga fighters on the outskirts of Mosul, Iraq, on January 26, 2015. Azad Lashkari/Reuters

Also critical to the death of ISIS' leader were the Syrian Kurds, whom the US effectively abandoned by pulling troops from northeastern Syria, allowing Turkey to invade.

The Kurds have long been a close ally in the fight against ISIS, and they lost more than 11,000 troops while working with the US to cripple the terrorist group over the past five years. But the president distanced himself from them after announcing the Syria retreat, saying among other things that the US didn't have to help the Kurds because they didn't help the US during World War II.

The Kurds, meanwhile, referred to Trump's actions as a betrayal, a sentiment that was echoed by US officials, Democrats, and even some Republicans.

Trump, asked on Sunday about what role the Kurds played in al-Baghdadi's capture and death, said they had "not a military role at all, but they gave us some information that turned out to be helpful."

But it appears the Kurds were more integral to the operation than the president indicated.

Read more: US troops demolished ISIS leader's suspected building to prevent it from becoming a shrine

In a press conference held shortly after Trump's, the Kurds said they began sharing intelligence about al-Baghdadi with the US five months ago. The Times reported that even after Trump retreated from Syria, the Kurds continued working with the CIA, helping to identify the ISIS leader's whereabouts and embedding spies within the group to monitor his movement.

Mazloum Abdi, the commander of the Kurdish-led Syrian Democratic Forces, told Foreign Policy he was the only foreigner to know about the target, an account independently confirmed to the outlet by a senior US official.

It's the intelligence community 'that he constantly derides that's helped him claim credit for killing Baghdadi'

President Donald Trump. Andrew Harnik/AP Images

Sunday's announcement was also noteworthy because it was perhaps the first time during Trump's three years in office when the president praised the US intelligence community.

"We had some incredible intelligence officials that did a great job," Trump said. "It's really a deserving name: intelligence."

The statement represented a stark departure from Trump's norm over the past few years.

The president has spent the better part of his time in office railing against the "deep state," a term coined by right-wing conspiracy theorists to refer to a secret cabal of US bureaucrats bent on overthrowing Trump.

Read more: Trump thanks Russia and other nations for helping with the US mission to kill ISIS leader al-Baghdadi

His resentment stems largely from the FBI's investigation into Russia's interference in the 2016 election, which highlighted several troubling interactions between the Trump campaign and Russia-linked individuals. The president's attitude soured further after an anonymous US intelligence official filed a whistleblower complaint that now poses the most serious threat to Trump's presidency.

"I've dealt with some people that aren't very intelligent having to do with intel," Trump said on Sunday. "When we use our intelligence correctly, what we can do is incredible. When we waste our time with intelligence that hurts our country, because we had poor leadership at the top, that's not good."

The comments painted a stunning picture.

In the middle of announcing the death of the most wanted man in the world — an outcome that would not have been possible without the intelligence community — the US president took time out to air his personal grievances against the officials who were part of that apparatus.

Aaron David Miller, a former State Department official and senior fellow at the Carnegie Endowment for International Peace, told USA Today he found Trump's praise for the intelligence community ironic. "It's the very professional intelligence community that he constantly derides that's helped him claim credit for killing Baghdadi," he said.

The president has actively sought to undermine intelligence findings related to not just Russia but also other hot spots like Iran and North Korea. He's also accused the intelligence community of being "un-American" and suggested officials who speak out against him are guilty of treason — a felony with the death penalty.

On the global stage, Trump publicly sided with Russian President Vladimir Putin — who ordered his government to interfere in the 2016 election — over US intelligence officials during a summit in Helsinki last year. And he accused current and former senior officials of conspiring with Democrats and Ukraine to undermine his presidency.

So when Trump changed course on Sunday and heaped praise on the intelligence apparatus, it fell flat for some.

Chris Whipple, the author of "The Gatekeepers: How the White House Chiefs of Staff Define Every Presidency," told USA Today he thought Trump's comments were "grudging at best."

Whipple added that Trump never directly mentioned the CIA and "that's no coincidence."