Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

For seven years, American federal agent Andrew Hogan was hot on the trail of one of the world's most elusive and brazen drug bosses, Joaquín Guzmán.

Agents had finally grabbed Guzmán — also known as "El Chapo," Mexican-Spanish slang for "Shorty" — in 2014 at a beach resort in Mazatlán, Mexico.

For their first face-to-face meeting, Hogan wore a black ball cap that once belonged to Guzmán — what he called a "souvenir of the hunt." He couldn't contain his excitement in front of the reputed cartel kingpin.

"What's up, Chapo?" were Hogan's first words to the man he had been pursuing so tirelessly.

The former Drug Enforcement Administration agent revealed his role in tracking Guzmán in an exclusive interview Wednesday on "Today," and will share more details Sunday with NBC News' Lester Holt on "Dateline."

Guzmán had eluded authorities for over a decade after escaping from a Mexican prison in 2001, going undetected from safe house to safe house as the Sinaloa Cartel continued trafficking billions of dollars worth of cocaine, methamphetamine and other drugs across international borders.

The Morning Rundown Get a head start on the morning's top stories. This site is protected by recaptcha

Hogan said Guzmán was always one step ahead, but DEA agents and Homeland Security investigators finally caught up with him "by looking at the details."

"We began intercepting members of Chapo's inner circle, and really dismantling layers within a sophisticated communications structure until we got to the top, where I had his personal secretary's device, who was standing right next to him, and I could ping that," Hogan said.

That helped agents to determine a pattern of where Guzmán was holed up. Eventually, the clues led them to a hotel in Mazatlán, where the Mexican marines banged on the door of his room. He gave up without a fight.

"I heard excited radio chatter: 'They got him! They got the target!'" Hogan said.

He arrived to the scene and confronted Guzmán in the underground parking garage of the hotel, where Hogan briefly spoke to him and they locked eyes.

But the years-long saga wasn't over. The following summer, Guzmán escaped in dramatic fashion from his maximum-security prison via a tunnel built below the shower in his cell.

He was captured six months later with the help of informants, satellite imagery and intercepted cellphone communications.

Guzmán was extradited to the U.S. in 2016 to stand trial on charges that he ran the world's largest drug-trafficking cartel, which is also accused of carrying out hundreds of murders. The 61-year-old remains at a federal facility in New York City, and because of past escapes, is locked up in near-isolation.

His trial was moved from this April to September as prosecutors and defense attorneys pore over more than 300,000 pages of documents related to the sprawling case.

Hogan has kept his role in initially capturing Guzmán under wraps, until now, with the release of his book, "Hunting El Chapo."

Sony Pictures won the rights to the book for a movie — a deal that Guzmán apparently wanted for himself after Mexican officials said he boasted that his life's story should be turned into a Hollywood biopic.