(CNN) In 2005, the US Drug Enforcement Administration embarked upon an unprecedented operation: to capture the man they described as "the most prolific drug dealer in the world."

His name is Haji Bagcho, and the DEA described him as a "criminal mastermind" of one of the largest heroin operations in Afghanistan. Agency sources said he had been dealing heroin and opium -- both derived from the poppy plant found in the region -- since the early 1990s.

By the mid-2000s, the ties between heroin and terrorism were growing. This prompted the DEA for the first time to form special commando-style units called Foreign-deployed Advisory Support Teams (FAST), and then deploy them to Afghanistan alongside US troops fighting the war against Taliban forces.

During the next four years, FAST teams and the US military planned and executed dangerous missions aimed at following Bagcho and his associates. They gathered intelligence about him and his massive operation and raided and searched his offices.

Bagcho's business records proved he was moving drugs at a staggering pace. From March 2006 to March 2007, Bagcho and his network distributed 231,000 kilograms of heroin, the DEA said.

A single kilogram of heroin, according to the DEA, can eventually generate approximately $1.5 million -- meaning Bagcho was generating a potential annual revenue stream worth billions of dollars.

"At a minimum we know he distributed approximately 20% of the world's heroin," DEA Supervisory Special Agent Phillip Kearney told CNN's Original Series "Declassified." "Haji Bagcho was kind of the godfather. He was really the man in the shadows that was in charge."

The DEA also suspected Bagcho of paying the Taliban to protect his opium labs.

Taliban terrorists used money from drug traffickers to fund terrorist attacks, the DEA said.

"Heroin trafficking is funding 37% of all the world's terrorist organizations," DEA Supervisory Special Agent Jeffrey Higgins told "Declassified."

Bagcho had offices in Pakistan as well as Afghanistan, the DEA said. He also had "distribution networks in 22 countries around the world," said Higgins. "To just look at him you would never think that this little man had caused so much death."

Wartime mission?

"The DEA doesn't have a wartime mission," Special Agent Kearney noted. "However, when we started to see the link between the heroin traffickers around the world and the US troops that were being killed by terrorists, we thought it was our duty to take the people out that were responsible for moving all the heroin and then moving money back to the terrorist organizations."

The first FAST international tactical teams hit the ground in Afghanistan in 2005. Trained in paramilitary operations, their goal was to help train Afghan police and execute drug interception missions.

"Our purpose was not military strikes to take [Bagcho] out. Our purpose was to get the evidence needed to prosecute him in United States courts," Kearney said.

"It was kind of groundbreaking. ... It was at a level of danger that [the DEA] had not seen since we had taken out some of the cartel heads in Colombia."

JUST WATCHED What was the DEA doing in Afghanistan? Replay More Videos ... MUST WATCH What was the DEA doing in Afghanistan? 01:01

Working closely with the US military and Afghan authorities, the operation to take down Bagcho began with DEA operatives -- some with concealed identities -- gathering intelligence on him and his network. In 2006, DEA agents developed a source who could get access to Bagcho and strike a deal with him.

Executing a search warrant, a FAST team raided Bagcho's home. But immediately before the DEA arrived, Bagcho was able to slip away, escaping to remote tribal areas across the Afghan border in Pakistan.

Months later, the trail led to a massive market in downtown Jalalabad, Afghanistan, where DEA agents conducted a search for a handwritten ledger with Bagcho's financial records. Agents found the ledger, providing a key piece of evidence that helped to close the loop in the investigation.

JUST WATCHED Ledger book links a drug kingpin to terrorism Replay More Videos ... MUST WATCH Ledger book links a drug kingpin to terrorism 00:54

Meanwhile, Bagcho fell off the DEA radar. FAST teams started finding and raiding drug labs along the mountainous Afghan-Pakistan border.

In early 2009, the DEA was informed that Pakistan's intelligence service had picked up Bagcho for having false identification documents. The US State Department reached out to Pakistan and arranged for Pakistan to hand over Bagcho at a border crossing. He was taken to an Afghan jail and eventually extradited to the US for trial.

JUST WATCHED Drug money pays for attacks on Americans Replay More Videos ... MUST WATCH Drug money pays for attacks on Americans 01:31

A US District Court jury in Washington, D.C., convicted him in 2012 of "one count of conspiracy to distribute one kilogram or more of heroin, knowing and intending that it would be unlawfully imported into the United States; one count of distribution of one kilogram or more of heroin" and one count of narco-terrorism. He was sentenced to life in prison for each charge, to be served concurrently.

In 2015, a federal judge voided Bagcho's narco-terrorism conviction after questions were raised about a witness' testimony, Higgins said. The Justice Department chose not to retry Bagcho on the narco-terrorism charge because he was serving life sentences on the other charges, he explained.

Bagcho has been imprisoned at the US "Supermax" prison in Florence, Colorado, said Higgins. The US Marshals Service says it has custody of Bagcho while attorneys in Washington prepare for his re-sentencing without the narco-terrorism conviction. He will still spend the rest of his life in prison.

Five years after Bagcho's conviction, statistics show the links between heroin and terrorism in Afghanistan remain strong.

1. Afghanistan is still a hotbed of global terrorism

2. Drugs provide major funding for the Taliban

-About half of the Taliban's annual $400 million income is likely "derived from the illicit narcotics economy," the UN report said

3. The amount of Afghan opium is rising

-Afghanistan's average opium yield per 2.5 acres increased 30% in 2016, compared with the previous year, according to the UN

4. More opium = more terrorism

-Since 2010, rising opium production has "shown a closer correlation with rising terrorist attacks," the 2017 UN report said

5. Billions have been spent but production remains high