Before the U.S. military positively identified the headless body of the world’s most wanted terrorist killed in a daring raid, a Kurdish spy slipped into Abu Bakr al-Baghdadi’s compound and stole his underwear to confirm the long-sought ISIS leader's identity through DNA, a Kurdish official said.

Syrian Democratic Forces (SDF) senior adviser Polat Can said Monday that the Kurdish-led force’s own sources tracked al-Baghdadi to Idlib, Syria, before beginning to work with the CIA to keep tabs on the terror leader. He said al-Baghdadi was known to move often and was soon expected to change locations.

HOW ISIS LEADER AL-BAGHDADI'S HEADLESS BODY WAS ID'D MINUTES AFTER DEATH

Before al-Baghdadi could move, a Kurdish undercover operative was able to reach him and retrieve the self-styled “Caliph’s” underwear, Can said. Through a DNA test, he said they were able to confirm “100%” that the person of interest was al-Baghdadi.

“All intelligence and access to Al Baghdadi as well as the identification of his place, were the result of our own work,” Can wrote. “Our intelligence source was involved in sending coordinates, directing the airdrop, participating in and making the operation a success until the last minute.”

AL-BAGHDADI INFORMANT WAS INSIDE COMPOUND AT TIME OF RAID, KURDISH GENERAL TELLS FOX NEWS

In announcing al-Baghdadi’s death, President Trump had said the Kurds provided “helpful” information but didn’t provide “a military role at all.”

While U.S. officials have not confirmed Can’s account, Gen. Mazloum Abdi, the SDF commander, had told Fox News on Monday that the Kurdish force had an informant inside the compound at the time of the raid. The agent had told them about the tunnels under the compound, how many people were with al-Baghdadi and about his planned move.

Al-Baghdadi was killed after he fled down a dead-end tunnel with three children – where he was found "whimpering" and trapped – and detonated a suicide vest.

WHO'S LEADING ISIS NOW THAT AL-BAGHDADI IS DEAD?

Al-Baghdadi’s head remained intact following the blast, allowing commandos to use biometrics, specifically facial recognition, to immediately identify him. Trump said they had also brought along samples of al-Baghdadi’s DNA to verify his identity with an onsite test that produced positive results in only 15 minutes.

People look at destroyed houses near the village of Barisha, in Idlib province, Syria, Sunday, after an operation by the U.S. military which targeted Abu Bakr al-Baghdadi, (AP)

It was unclear what kind of devices were used to positively identify al-Baghdadi, but over the past several years the military has been developing technology for portable DNA labs that process results quickly.

The technicians were able to take “substantial pieces” of al-Baghdadi’s remains from the site, Trump said.

AL-BAGHDADI KILL: HOW THE DARING MILITARY OPERATION WENT DOWN

On Monday, Army Gen. Mark A. Milley, chairman of the Joint Chiefs of Staff, said that al-Baghdadi’s remains were “disposed of appropriately” in accordance with the law of armed conflict, but didn’t elaborate.

A source has told Fox News he was buried at sea, similar to Al Qaeda leader Usama bin Laden, who was killed in 2011.

While it remains unclear who exactly will take over the terror organization, Trump confirmed on Tuesday that al-Baghdadi's "number one replacement" was killed by American troops, without naming the target.

A senior State Department official had confirmed to Fox News on Monday the death of ISIS spokesman Abu Hassan al-Muhajir, who was considered al-Baghdadi's right-hand man.

CLICK HERE FOR THE FOX NEWS APP

The void in leadership is the latest significant setback for the terror group after having already lost vast stretches of its physical caliphate that stretched across parts of Syria and Iraq.

Fox News' Benjamin Hall and Jennifer Griffin contributed to this report.