— Joaquín “El Chapo” Guzmán, the world’s most famous drug lord, escaped from a ­maximum-security prison in Mexico for the second time in his drug-running career, a spectacular breach of security that set off a wide-ranging manhunt early Sunday.

For the past year and a half, the leader of the Sinaloa cartel had been incarcerated in the Altiplano, a federal facility set amid farmland west of the capital that holds the top captured drug bosses and has been described as the country’s most impenetrable prison.

That changed late Saturday, when Guzmán slipped out of the prison through a rectangular opening in the shower area of his cell that led to a nearly mile-long tunnel running out of the prison, underneath rolling corn fields and cow pastures and ending at a small cinder-block house decorated with Christmas lights that residents say was built after Guzmán’s imprisonment.

“They say this is maximum security?” Luis Alberto Carmona, 32, a farmer who lives in a house overlooking the prison, said Sunday afternoon. “This is the national security of our country. They have the most dangerous criminals in there. . . . How could this happen?”

Guzmán’s escape is a staggering blow for Mexican President Enrique Peña Nieto, who had been building a strong reputation for arresting top drug bosses from all the major cartels.

And it promises to be a major irritant in relations between the U.S. and Mexican governments. American officials had pressed for Guzmán’s extradition so that he could be prosecuted for drug crimes and held in a more secure facility.

But the Peña Nieto administration refused to grant his extradition to the United States, insisting that it would prosecute Guzmán at home, as a showcase of Mexican judicial independence. Guzmán remained at Altiplano — until Saturday night.

“This represents, without a doubt, an affront to the Mexican state,” Peña Nieto said while on a state visit to France with many top officials, some of whom rushed back to Mexico.

Attorney General Loretta E. Lynch issued a statement Sunday in which she said that the United States was prepared to offer any assistance necessary to help recapture the fugitive.

At a brief morning news conference, Mexico’s national security commissioner, Monte Alejandro Rubido, said Guzmán was last seen in the prison about 8 p.m., when he received his daily dose of medication. After guards realized he had disappeared, they found a hatch that led by ladder down to the tunnel, which was illuminated, perforated with PVC piping for ventilation and equipped with an adapted motorcycle-on-rails to whisk the drug lord to freedom.

Those living near the barbed-wire enclosed prison and the tunnel house said that helicopters and police trucks fanned out about 9 p.m. Saturday in search of Guzmán.

The manner of his escape suggests that his rescue operation was well planned and well financed and may have occurred with the complicity of officials in the prison.

He may have been aided by a large construction project going on directly outside the prison’s perimeter fence. As part of a water-pipeline project, started about a year ago, according to residents, builders have been digging a deep trench and installing rows of tubing adjacent to the facility. Neighbors said it has been common to see earth-
movers and dumptrucks, which may have made Guzmán’s ­tunnel-builders more difficult to detect.

The one-story cinder-block structure where the tunnel ended is in Santa Juana, an area between the prison and a nearby military base. Authorities blocked it off with police tape Sunday while they investigated. The closest neighbor, on a farm with corn and cattle, said that the cinder-block house was built within the past year and that he had noticed nothing unusual in recent months, until a helicopter touched down next to it Saturday evening.

“It’s unbelievable, but in Mexico, anything can happen,” said the neighbor, who spoke on the condition of anonymity because he didn’t want to get involved in the case. Looking over the fields to the prison, he said, “They snatched him right out of there.”

Authorities put the Altiplano prison, in the area of Almoloya de Juarez in the state of Mexico, on lockdown after Guzmán’s escape. No one was allowed in or out, and troops and police officers deployed to the area to search for the fugitive. Flights out of the nearby Toluca airport were grounded, Rubido said, to prevent Guzmán from leaving that way. Thirty prison staff members were taken in for questioning.

But in the Sinaloa cartel, Guzmán still has a large and lucrative drug-running operation to welcome him back into the fold.

“Chapo’s escape is extremely disappointing to the United States,” said Mike Vigil, the Drug Enforcement Administration’s former director of international operations. “Within 48 hours, Chapo will reassume control of the Sinaloa cartel, which means more violence for Mexico and more drugs to the U.S.”

Mexican officials took it as a point of pride and national sovereignty that they could imprison drug traffickers as powerful as Guzmán. But privately, many in Mexico City concede that the government would be loath to send him north, knowing he could reveal the extent to which his cartel’s tentacles were able to penetrate the highest levels of the Mexican government and security apparatus.

Although the Peña Nieto administration has succeeded in weakening some cartels, such as the Zetas and the Knights Templar, others are now ascendant, including the New Generation cartel in Jalisco. And the failure to hold the country’s most powerful drug trafficker reveals the weakness of Mexico’s justice system and will add to the perception that the state has become riddled with corruption.

“All the accolades that Mexico has received in their counter-drug efforts will be erased by this one event,” Vigil said. “It will be very difficult to capture Chapo if he is able to make it into the rugged Sierra Madre mountains of Sinaloa, where he was born and raised. He is revered and protected by the local population since he builds schools, churches and gives money to the poor.”

Vigil said Guzmán is the only drug trafficker to escape from two maximum-security prisons in Mexico and is the only one to escape from Altiplano, built in 1990. “This will only add to his legendary status,” he said.

In February 2014, Guzmán was captured by a team of Mexican commandos while he was sleeping in the Miramar condominium in the beach town of Mazatlan. The arrest came after a series of military operations that relied heavily on intelligence gathered by U.S. law enforcement officials and that led to houses with their own elaborate tunnel network in the Pacific coast state of Sinaloa, used by Guzmán for years to evade capture.

While he was in prison, reports emerged that Guzmán had helped organize a hunger strike to protest living conditions. Those with access inside noticed some small perks; for example, while others were forced to shave, he could keep his mustache. Six days ago, Guzmán’s son, Ivan, tweeted, “Everything comes to those who know how to wait.”

Guzmán had risen to be the most-wanted man in Mexico and the leader of a sprawling drug-running operation with links in dozens of countries. He was arrested in 1993 in Guatemala but escaped from another Mexican maximum-security prison in 2001, aided by prison guards.

Even with Guzmán in jail, his Sinaloa organization remained the dominant narcotics smuggling power in Mexico, with trafficking networks that spread across the United States. Guzmán’s cartel sends more cocaine and marijuana than any other into the United States, according to DEA officials, and it accounts for more than half of the heroin surging into U.S. communities as overdose deaths skyrocket.

“Obviously, we are extremely unhappy,” a senior DEA official said Sunday of Guzmán’s escape. The official, who spoke on the condition of anonymity because the matter was so sensitive, did not say whether the United States was aiding in the manhunt.

In her brief statement, Lynch said U.S. officials “share the government of Mexico’s concern” following Guzmán’s escape.

“In addition to his crimes in Mexico, he faces multiple drug trafficking and organized crime charges in the United States,” read her statement, in what was perhaps a subtle dig at Mexico’s refusal to extradite him.

“The U.S. government stands ready to work with our Mexican partners to provide any assistance that may help support his swift recapture,” Lynch’s statement read.

Guzmán’s longtime business partner, Ismael “El Mayo” Zambada, was believed to have assumed operational control of the cartel after Guzmán’s arrest, though few in Mexico doubted that Chapo continued calling the shots from his cell.

The group’s hideouts, safe houses and drug ranches span a vast area in the rugged northern Sierra Madre, where men such as Guzmán and Zambada are viewed by many as Robin Hood-like folk heroes.

Gabriela Martinez in Mexico City contributed to this report.