According to a former American official and another person briefed on the matter, the force behind the cartel’s rapid and effective response was yet another Guzmán — El Chapo’s older son, Ivan, who has taken a prominent role in the cartel since his father was caught, extradited to the United States and sentenced to life in prison in July on drug, murder and money laundering charges.

They said that Ivan was initially captured by the military as well, but that his henchmen quickly overpowered the armed forces and secured his release. Once free, the elder brother then orchestrated a staggering show of force to secure the freedom of his brother, Ovidio.

The effort not only included holding soldiers hostage, but also kidnapping their families, according to the two people briefed on the matter, who were not authorized to speak publicly. Government press officers did not respond to requests for comment.

The cartel’s victory offered a frightening glimpse into the power wielded by organized crime in Mexico, distilling in a single, eight-hour stretch the extent to which the nation is held captive by criminal networks — without a plan to combat the scourge of violence that has brought the country to its deadliest point in decades.

It was a major loss of face for a president who has consistently waved off doubts about his security strategy — or, in the eyes of critics, his lack of one.

Like his predecessor, Mr. López Obrador has tried to distance himself from the violence tearing at his nation, opting instead to focus on a slate of domestic programs to target poverty.