Correction: An earlier version of this story erroneously said that Joaquín Guzmán was found in bed with his secretary. He was found with his wife. This version has been corrected.

Mexico most-wanted drug trafficker, Joaquin “El Chapo” Guzmán, was arrested Saturday after a months-long operation to track him down, according to U.S. and Mexican authorities. (Reuters)

The half-dozen Mexican commandos who burst into Room 401 of the Miramar condominium building in the beach town of Mazatlan found the world’s most wanted drug lord not armed to the teeth but shirtless and curled up in bed with his beauty-queen wife. An assault rifle was at his side, but he didn’t try to grab it.

The arrival of the elite troops at this seaside condo tower on Saturday morning marked the culmination of nine days of rapid-fire military raids and detective work across the Pacific coast state of Sinaloa.

Mexican and U.S. authorities involved in the investigation offered new details Sunday about how they put together a jigsaw puzzle that was 13 years in the making. They were helped by U.S.-supplied wiretaps and surveillance technology that allowed them to track the cellphone locations of Joaquín “El Chapo” Guzmán and his crew as they tried everything to avoid capture — even fleeing through sewer tunnels.

The arrest is a major victory for Mexican President Enrique Peña Nieto, whose government and that of his predecessor had faced accusations that they had accommodated Guzmán’s Sinaloa cartel while targeting other groups. The drug lord’s capture shows that “we don’t have agreements with anyone,” said Tomas Zeron, the head of criminal investigations in the Mexican attorney general’s office. “The investigation was very good, and very well coordinated over many days, and this was the result.”

American law enforcement officials played a key role in the successful pursuit of the leader of the Sinaloa cartel, one of the wealthiest and most powerful drug-running outfits in the world, according to U.S. and Mexican officials.

For at least a year, U.S. Immigration and Customs Enforcement agents, as well as Drug Enforcement Administration agents and members of the U.S. Marshals Service, had worked the case. A key break occurred in November, at the border in Nogales, Ariz., when a son of Guzmán’s top lieutenant, Ismael “El Mayo” Zambada, was arrested, according to a U.S. federal law enforcement official.

From that arrest, U.S. federal agents gained information that enabled them to map the upper reaches of the Sinaloa cartel. They learned about some of the places where Guzman, 56, and his henchmen liked to sleep when they came to cities in the western state. “We were able to penetrate the inner circle,” the official said.

“It was a traditional drug investigation where one phone begets another phone that begets another phone,” he added. “It was really drug investigations 101.” He and other officials spoke on the condition of anonymity because they were not authorized to comment.

Current and former U.S. officials said that Guzmán’s “sloppiness” — specifically his more frequent trips from his mountain hideout to the cities of Culiacan and Mazatlan — also was key to the arrest.

A break in the case

The Americans shared the intelligence from the Arizona arrest with the Mexicans early this month. “We shared it live so they could do verifications as we were collecting it. They knew the cities,” another U.S. official said. That led to another big break on Feb. 13, when Mexican marines raided a farmhouse outside Culiacan, the Sinaloan capital. At the ranch, the marines arrested five people described as cartel hitmen, including Jose Enrique Sandoval Romero, known as “El Loco,” and two of his brothers, according to Mexican officials.

Using information from that arrest, the marines went to some of Guzman’s safe houses in Culiacan, including one where his ex-wife lived, officials said. In one home, they found one of Guzman’s couriers, who disclosed locations of more safe houses. Guzman was hiding in another of the houses, the officials said. As the marines tried to knock down its steel-reinforced door, they said, Guzman escaped through a trap door under the bathtub. He descended a steel ladder that led to a network of tunnels that wove through the sewer system and connected at least seven other houses, U.S. and Mexican officials said.

“He was able to escape from us at least twice,” said the U.S. federal law enforcement official. “He had a direct sense that we were after him.”

Guzman was moving quickly. He would leave behind grenades, rifles, ballistic vests and armored cars. “He was on the run, and he had to leave behind his personal protection,” one federal law enforcement official said.

As police closed streets in Culiacan and searched houses, top officials of the Mexican navy and the federal prosecutor’s office were holding emergency meetings to coordinate the hunt for Guzmán, who had escaped from a high-security prison in 2001. U.S. officials said he had since become the world’s most powerful drug lord.

American investigators sifted through the trove of new intelligence, and “all the agencies started to strategize, looking at stash houses, associates — and the puzzle started coming together,” according to Mike Vigil, a retired senior DEA official who worked for 13 years in Mexico and was briefed on the arrest.

Mexican officials said the United States contributed with technology that allowed them to track cellphones and satellite phones used by the cartel.

On Wednesday and Thursday, three more Guzmán lieutenants were arrested in Culiacan, officials said. One of the men had a stockpile of thousands of cocaine-filled bananas and cucumbers.

At that point, “Chapo and his guys realized they needed to drop the cell communication,” another federal official said. “They knew something was up.”

On Friday, instead of heading back to the mountains, Guzman traveled by road to Mazatlan, about 135 miles south of Culiacan.

Meanwhile, one of the wiretaps that originated out of the Nogales arrest had picked up the number for a new cellphone. It turned up in the pocket of Guzman’s traveling companion, a man known as “El Condor.”

Guzmán had arrived at the condo with El Condor and a woman whom U.S. officials initially described as his secretary and lover. But senior American officials, as well as Zeron of the Mexican attorney general’s office, said the trafficker was with his wife, Emma Coronel, and their toddler daughters. twin 2-year-old daughters. The girls were born in a Los Angeles County hospital and are U.S. citizens.The Mexican navy commandos burst into the room at 6:40 a.m. and found Guzmán asleep.

“He didn’t put up any resistance,” Vigil said. “He was physically tired from the stress of being hunted.”

Guzmán has been taken to a maximum-security prison in Almoloya de Juarez in the state of Mexico, outside Mexico City.

U.S. Justice Department spokesman Peter Carr said the decision on whether Guzman will be tried in Mexico or the United States “will be the subject of further discussion” between the two countries.

For now, officials are relieved to have captured the trafficker.

“This is a huge case,” a U.S. official said. “A big deal for us and a big deal for the Mexicans.”

Horwitz reported from Washington. Ernesto Londoño and Julie Tate in Washington, as well as Nick Miroff, contributed to this report.