In their long hunt for Abu Bakr al Baghdadi, Iraqi intelligence teams secured a break in February 2018 after one of the Daesh leader's top aides gave them information on how he escaped capture for so many years, said two Iraqi security officials.
Baghdadi would sometimes hold strategy talks with his commanders in moving minibuses packed with vegetables in order to avoid detection, Ismael al Ethawi told officials after he was arrested by Turkish authorities and handed to the Iraqis.
"Ethawi gave valuable information which helped the Iraqi multi-security agencies team complete the missing pieces of the puzzle of Baghdadi's movements and places he used to hide," one of the Iraqi security officials said.
"Ethawi gave us details on five men, including him, whom were meeting Baghdadi inside Syria and the different locations they used," he told Reuters.
US President Donald Trump said on Sunday that Baghdadi died "whimpering and crying" in a raid by US special forces in the Idlib region of northwest Syria.
In a televised address from the White House, Trump said the Daesh leader died alongside three of his children when he detonated an explosives-laden vest after fleeing into a dead-end tunnel during the attack.
The path to Baghdadi's demise was full of frustrations for Western and Arab intelligence agencies, who have pored over clues to the whereabouts of a man who imposed a reign of terror across a large swathe of Syria and Iraq, ordering his men to carry out mass executions and beheadings.
He is also responsible for gruesome attacks across five continents.
Turning militants such as Ethawi was critical to the agents trying to track Baghdadi.
Ethawi, who holds a PHD in Islamic Sciences, was considered by Iraqi intelligence officials to be one of the leader's top five aides.
He joined al Qaeda in 2006 and was arrested by US forces in 2008 and jailed for four years, according to the Iraqi security officials.
Baghdadi later tasked Ethawi with key roles such as delivering instructions and the selection of Daesh commanders. After the group largely collapsed in 2017, Ethawi fled to Syria with his Syrian wife.
Another turning point came earlier this year during a joint operation in which US, Turkish and Iraqi intelligence agents captured senior Daesh leaders, including four Iraqis and one Syrian, the Iraqi security officials said.
"They gave us all the locations where they were meeting with Baghdadi inside Syria and we decided to coordinate with the CIA to deploy more sources inside these areas," said one of the Iraqi officials, who has close ties to multiple security agencies.
"In mid-2019 we managed to locate Idlib as the place where Baghdadi was moving from village to village with his family and three close aides," the official said.
Informants in Syria then spotted an Iraqi man wearing a checkered headdress in an Idlib marketplace and recognised him from a photograph, the official said. It was Ethawi, and they followed him to the home where Baghdadi was staying.
"We passed the details to the CIA and they used a satellite and drones to watch the location for the past five months," the official said.
Two days ago, Baghdadi left the location with his family for the first time, traveling by minibus to a nearby village.
"There it was his last moment to live," the official said.
Baghdadi was also on the run from local enemies in Syria.
Hayat Tahrir al Sham, the group formerly known as the Nusra Front and which dominates Idlib, had been mounting its own search for Baghdadi after receiving information he was in the area, according to a commander in a militant group from Idlib.
The Nusra Front and Daesh were rivals who fought bloody battles against each other in the Syrian war.
The Nusra Front, founded by Abu Mohamad al Golani, was al Qaeda's official affiliate in Syria until it broke away from the global terrorist network in 2016.
According to the Idlib commander, Hayat Tahrir al Sham recently captured another aide to Baghdadi known as Abu Suleiman al Khalidi, one of three men seen sitting alongside Baghdadi in his last video message.
The capture of Khalidi was "the key" in the search for Baghdadi, the commander said.
His comments raised the possibility that Hayat Tahrir al Sham, which locals say is believed to have contacts with Turkish forces in northwest Syria, may have passed on what it learned to other intelligence agencies.
Baghdadi may have concluded that hiding in Idlib was his best hope after Daesh was all but wiped out in Iraq and Syria.
He could have blended in, while lax security and checkpoints operated by armed groups that rarely search vehicles increased his chances of survival, the commander said.
He said Baghdadi was believed to have been in Idlib for about six months, and that his main reason for being there was to try to hide.
But he said Baghdadi was still seen as a major threat because his presence would have attracted supporters in an area where Daesh has sleeper cells.
Hayat Tahrir al Sham fighters raided the town of Sarmin about two months ago after receiving information about Baghdadi being there, but he was not found, according to the commander.