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

Infamous Mexican drug kingpin Joaquin “El Chapo” Guzman, who humiliated authorities when he tunneled out of a maximum-security prison in July, was recaptured early Friday in a deadly raid by Mexico's navy.

Guzman is being transported back to Altiplano — the same maximum-security prison where he escaped on July 11 using an elaborate tunnel that was dug under his shower stall, Attorney General Arely Gomez Gonzalez said at a news conference late Friday.

“Mission accomplished,” Mexico's President Enrique Peña Nieto said on Twitter Friday. “We have him.”

The drug boss was tracked down partly because he planned to make a biographical movie about his escape and his people had been in contact with actors and producers, which led officials to his safe house, Gonzalez said.

RELATED: Who Is 'El Chapo?': Meet Infamous Drug Lord

The Mexican Navy carried out the operation, according to leading Mexican newspaper El Universal. The navy, seen as less corruptible than the country’s police forces and army, has taken the lead in fighting the cartels.

The navy said in a statement that marines, acting on a tip, stormed into a home in the town of Los Mochis before dawn. They were fired on from inside the building. Five suspects were killed and six others arrested, according to the statement.

Drug kingpin Joaquin "El Chapo" Guzman is escorted by marines to a helicopter at Mexico City's airport on January 8, 2016. OMAR TORRES / AFP - Getty Images

Michael Braun, the former DEA chief of operations, confirmed the details of the arrest to NBC News.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

"It’s huge. I mean, he’s the number one drug-trafficking figure in history and he’s been probably the world’s biggest criminal fugitive,” a senior DEA official said. “And so it’s a huge win for the rule of law. No one is above it, and it’s great for the government of Mexico and the U.S., and the world.”

Guzman faces charges in numerous jurisdictions across the United States. While the Justice Department doesn’t comment on extradition requests, a senior official said: “I can confirm that it is the practice of the United States to seek extradition whenever defendants subject to US charges are apprehended in another country.”

Guzman, leader of the Sinaloa drug cartel and a master of underground tunnels, set off a furious manhunt on July 11 when he casually slipped into a hole in his shower at Altiplano prison near Mexico City and fled through a mile-long tunnel outfitted with a motorbike that led to a residential construction site.

Drug lord "El Chapo"

The Hollywood-style escape was a huge embarrassment for Mexican officials — in particular because Guzman and his organization were known for building tunnels under the U.S.-Mexico border. Guzman had escaped from prison once before, in 2001, purportedly hidden in a laundry cart.

PHOTOS: A Glimpse Inside ElChapo's Tunnel

Nieto on Friday thanked the agencies that he said conducted “months of careful and detailed intelligence work” and worked “for days and nights tirelessly to accomplish the mission that I have asked them to do.”

“Our institutions have shown once again that the citizens can trust these institutions,” Peña Nieto said. “Our institutions are good enough. They have the determination.”

“Mexico is very proud,” Peña Nieto said. “We’re going to continue to fight organized crime.”

Since the Altiplano escape, 23 prison officials and employees have been arrested, and several of Guzman’s Sinaloa underlings have been rounded up. The getaway damaged relations between Mexican and American anti-drug authorities, who had warned that Guzman's associates would try to break him out of Altiplano.

After fleeing the prison, Guzman traveled by land to the city of Queretaro, where officials say he caught a small plane to a mountainous region of Sinaloa, his home state and stronghold, Attorney General Arely Gomez has said. A second plane also took off in an apparent attempt to throw off pursuers.

The escape was organized by a member of Guzman's legal team who had access to Altiplano and was able to keep his boss updated on the plan's progress, authorities have said.

A Guzman brother-in-law is also believed to have supervised construction of the tunnel. A third conspirator allegedly negotiated the purchase of the plot of land where the tunnel emerged.

Marines nearly captured Guzman in October after U.S. drug agents intercepted cell phone signals that led them to a ranch in the Sierra Madre Mountains in western Mexico, sources told NBC News at the time. But the government forces were turned back by heavy gunfire, and Guzman was able to flee. Officials believe he was injured in that near-miss.

A U.S. Drug Enforcement Administration statement said El Chapo’s capture was “a victory for the rule of law and the Mexican people and government.”

U.S. Attorney General Loretta Lynch commended the Mexican government for the arrest. “Guzman’s latest attempt to escape has failed, and he will now have to answer for his alleged crimes, which have resulted in significant violence, suffering and corruption on multiple continents,” she said in a statement.

Drug lord "El Chapo"

Guzman, believed to be about 60, has long been a popular anti-hero in Sinaloa and across Mexico for dodging death and evading bullets while turning the multibillion-dollar Sinaloa cartel into the world's most powerful — and ruthless — drug trafficking organization.

His exploits are chronicled in folk songs. Young people in his impoverished home state rally in support of him, despite his being responsible for the murders of thousands of Mexicans, including police officers and innocent civilians.

Secretive and nearly illiterate, Guzman oversaw the explosion of subterranean networks used to smuggle massive amounts of narcotics across the U.S. border. After his 2001 escape, he outfitted many his safe houses with secret doors that opened to tunnels leading to municipal sewer systems. He used one of them, accessed through the bottom of a bathtub, to shake authorities in February 2014.

Guzman was caught a few days later, an arrest that was hailed as a major victory in the international war on drugs. He ended up in Altiplano, where he began planning the July escape.