"His relatives were subjected to harsh treatment by ISIS and he no longer believed in the future of ISIS. He wanted to take revenge on ISIS and Baghdadi himself," General Mazloum Abdi told NBC News.
ISIS leader Abu Bakr Al-Baghdadi was betrayed by a member of his inner circle who helped lead American troops to his compound in Northern Syria.
The commander of the Kurdish-led Syrian Democratic Forces, General Mazloum Abdi, gave NBC NEWS a detailed account of how he ran a spy inside ISIS for months, who followed Baghdadi as he moved from one safehouse to another until he was finally trapped in a tunnel beneath one of them.
Abdi did not identify the source, but Kurdish intelligence officials described him as an Arab who had many relatives in ISIS.
Abdi said the informant's main motivation was revenge.
"I think he was under a lot of pressure from his family," the general said. "His relatives were subjected to harsh treatment by ISIS and he no longer believed in the future of ISIS. He wanted to take revenge on ISIS and Baghdadi himself."
The spy was in a unique, and extremely rare position to exact his revenge.
"He was, you could say, a security official," the general said. "A personal security official for Baghdadi himself, in charge of Baghdadi's movements. "
Part of the informant's job, Abdi said, was "securing the places" where Baghdadi would later hide.
This ISIS spy memorized the locations and layouts of Baghdadi's safehouses and even stole samples of the world's most wanted terrorist's blood and clothing for DNA analysis, the general said.
None of that was easy.
"Baghdadi took his security precautions to the highest level," Abdi said. "He never used high-tech communications at all. Any place he was in, was in a communications blackout, with exception of those who were directly responsible for his security, and that was a small group of people."
After years on the run, Baghdadi had a relatively small household.
"His direct family, the children, his relatives, his siblings, they are formed a tight ring around him," Abdi said. The ISIS leader only allowed a small group of outsiders to meet him. One of them was the spy.
Abdi declined to say when or how they first made contact with the ISIS informant, but he said in the last five months the relationship deepened and expanded dramatically. That coincided with Baghdadi's move from a hideout in eastern Syria to the Idlib province in western Syria, near the Turkish border.
"We confirmed that (Baghdadi) had been moved to Idlib in April of this year," Abdi said.
Idlib was an unlikely place for the ISIS leader to hide. The province is largely controlled by other Islamist groups, including one linked to al-Qaeda often called the Al-Nusra Front. The group has, at times, fought against ISIS. Abdi said he was hiding among a pocket of supporters, in what was largely unfriendly territory.
"The idea that Baghdadi was in Idlib was completely unexpected," Abdi said. "It was a surprise to everyone."
Idlib is a large province with a varied terrain, including hills, canyons, olive groves, and several large towns and cities. Abdi said the spy's meetings in Idlib were frequent but inconsistent. Kurdish intelligence officials said the spy could not approach the ISIS leader at will, but had to wait to be called for meetings. The face-to-face meetings -- ostensibly to talk about security, movements, transportation and setting up future safehouses -- would turn out to be critical.
To figure out where exactly Baghdadi was holed-up in Idlib province, Abdi said the spy had to rely on his senses and memory. Baghdadi's bodyguards would pick him up in a car, or sometimes a taxi. Most visitors to Baghdadi were blindfolded on the journey to the ISIS leader. But the spy was more trusted than most. Baghdadi's personal guards merely asked him not to look out the car windows.
"When they approached the area, they would ask him to lower his seat so he can't look around," Abdi said. "They asked him to lay down, to lower the seat in the taxi."
But even with the seat back flat, Abdi says the spy was able to pick up bits of the topography and could tell if he was in a town, or in the countryside, among olive groves or open fields.
Once inside Baghdadi's hideouts - and there were several, in close proximity to each other -- the spy was able to look around freely, the general said.
He started memorizing the internal spaces and distinguishing structural features that could be seen from above like a red water tank on a roof.
Those details, Abdi said, were fed constantly back to the Kurds and, through them, to American intelligence agencies, enabling U.S. aerial surveillance to pinpoint Baghdadi's final hideout. The descriptions of the compound helped American commandos plan their assault.
"He provided information about the house itself, the shape of the house and things to do with the house, the specifications of the house," the general said.
Like the tunnel where Baghdadi blew himself up with the U.S. forces chasing after him.
"We learned that there was a tunnel in the house," the general said. "We learned how many people in the house, how many guards were in the house. We learned the closest Al-Nusra checkpoints near the house. We learned all the security details of the house."
But before sending in the commandos, Abdi said, U.S. intelligence wanted concrete proof that the source had the access to Baghdadi that he claimed.
They wanted to make sure it wasn't all a hoax, or worse, a trap, Abdi said.
So the spy stole a pair of the ISIS leader's used underwear and later a blood sample to compare with known samples of Baghdadi's DNA. Baghdadi had been in U.S. custody in Iraq years before.
Abdi said the spy stole underwear roughly three months ago from a house Baghdadi had previously used and abandoned. He wouldn't say how the blood was collected, only that it was taken about a month ago. Abdi said both DNA tests matched, proving the spy's bona fides.
"After that, the CIA took this more seriously," Abdi said. "They began to work hard and serious on the highest level."
But the timetable for launching a raid on Baghdadi's compound was delayed by President Donald Trump's sudden decision to pull U.S. troops out of Northern Syria and the subsequent Turkish invasion.
Suddenly, Abdi said, his Kurdish-led forces had to focus more of their attention on defending themselves.
Meanwhile, Baghdadi was preparing to move yet again.
"Al Baghdadi had prepared a new house for himself in a different place located in the area of Dera al-Fraat (Jarablus area)," Abdi said. "That house was ready. I assume that within 48 hours he would have left the house to the new house, and the new house was completely different and wasn't known."
Abdi said the spy was at the compound when U.S. Special Forces attacked.
"He was there and he returned safely with the American forces," Mazlum said.
US officials have told the Washington Post he'll likely receive all or part of the $25 million bounty for Baghdadi's head.