(CNN) While Joaquin "El Chapo" Guzman sat in a Mexican maximum security prison in 2015, his sons, a former cartel associate and even his wife worked together to coordinate details of his final escape, according to the former associate's testimony.

Damaso Lopez, 52, wearing a navy-blue prison uniform, testified Wednesday against Guzman, who he once oversaw as a prison official but eventually went to work for. Lopez was not a prison official during either of Guzman's escapes, in 2001 and 2015.

Guzman dramatically escaped from prison in 2015, riding on a motorcycle through a tunnel that had been dug to his cell at the Altiplano maximum security federal prison.

Lopez testified that he had met with Guzman's four sons multiple times to coordinate the digging of a tunnel, the purchase of land near the prison and the renting of the warehouse where Guzman was taken before being flown to a hideout in his home state of Sinaloa.

Lopez said that Guzman's wife, Emma Coronel, would bring messages from Guzman to the group after visiting him in prison, requesting them to complete tasks for the escape.

Photos: Joaquin 'El Chapo' Guzman's 2015 escape Joaquin "El Chapo" Guzman was considered the world's most powerful drug lord until his arrest in Mexico in February 2014. He escaped from a maximum-security prison on July 11, 2015. Hide Caption 1 of 6 Photos: Joaquin 'El Chapo' Guzman's 2015 escape This screen grab of security video, dated July 11 and released by Mexico's National Security Commission, shows Guzman inside his cell at the Altiplano prison in Almoloya de Juarez, Mexico. He is looking at the shower floor shortly before escaping through a tunnel below, authorities said. Hide Caption 2 of 6 Photos: Joaquin 'El Chapo' Guzman's 2015 escape A journalist climbs a ladder to get out of the tunnel that authorities say Guzman used to escape. Hide Caption 3 of 6 Photos: Joaquin 'El Chapo' Guzman's 2015 escape Journalists exit the tunnel on Tuesday, July 14. Hide Caption 4 of 6 Photos: Joaquin 'El Chapo' Guzman's 2015 escape Yellow police tape surrounds the construction site where the exit of the tunnel is located. Hide Caption 5 of 6 Photos: Joaquin 'El Chapo' Guzman's 2015 escape Federal police guard a drainage pipe outside of the prison on Sunday, July 12. Hide Caption 6 of 6

Coronel sat in federal court in Brooklyn as Lopez testified against his former boss. She has not been charged with a crime and a spokesman for the US Attorney's office had no comment when asked whether Coronel could face charges due to the allegations.

Jeffrey Lichtman, Guzman's attorney, said, "I'm not concerned," when asked about the allegations against Coronel, and a spokeswoman for her had no comment.

Guzman, 61, has pleaded not guilty. If convicted of international drug trafficking, conspiring to murder rivals, gun charges and money laundering, he faces a sentence of life in prison.

The inmate becomes the boss

Damaso Lopez was a high-ranking Mexican prison official when he first met Guzman in 1999 at Puente Grande, a maximum security prison. The pair, Lopez testified, quickly became friends and did favors for each other.

Lopez was the deputy director of security and custody when he met Guzman and was responsible for internal security for the prison. Guzman, like other prisoners, would send Lopez signed, handwritten notes asking for items such as clothing and shoes. Guzman also asked for a contraband cell phone.

"He was able to check his email with that phone," Lopez testified.

Damaso Lopez, a former prison official turned associate of Joaquin "El Chapo" Guzman, testified Wednesday about details of Guzman's escape.

In exchange, Lopez testified, he received help, too. Guzman allegedly gave him about $10,000 and gave him a home worth 1.5 million Mexican pesos, about $78,000.

"When I needed anything, I would ask and he would give it to me," Lopez testified.

Lopez resigned from his post in 2000 after the prison was being investigated for corruption. In 2001, Guzman escaped from Puente Grande, hidden in a cart filled with dirty laundry.

Lopez said he was not involved in that escape, which brought Guzman more than a decade of freedom.

Lopez testified he stayed in touch with Guzman, turning to him when he struggled to find a job after resigning from his post at the prison.

"He offered me a job," Lopez said.

Over the next 15 years, Lopez would work for Guzman, who he called "mi compadre," my friend, throughout his testimony.

El Chapo at a prison in 1993. He would escape from another facility in 2001.

"In everything, my compadre was my boss," Lopez said.

When Lopez first took the stand Tuesday, he tapped his hand to his chest as he gazed over at Guzman. Guzman's attorney, Eduardo Balarezo, asked why he did this, and Lopez said it was "because I love him."

"He's a person I spent many years together and I have affection for him," Lopez said.

The pair became close after Guzman's 2001 escape from prison.

"Way too close," Lopez testified.

Lopez started to work for Guzman by helping acquire properties for him, he said. He became godfather to one of Guzman's twin girls. Later, Lopez would mine his government contacts for information about operations against Sinaloa cartel associates, and coordinate drug shipments.

Lopez testified that Guzman ordered multiple executions of cartel associates, some of which were not carried out. Lopez would sometimes serve as a messenger, allegedly delivering Guzman's execution orders. Lopez also testified that he himself kidnapped multiple people, but that he'd never killed anyone.

Then on February 22, 2014, Lopez's birthday, after more than a decade on the run Guzman was arrested and taken to a prison at the Altiplano federal penitentiary.

Plans for the escape

Guzman and Lopez continued to stay in touch while Guzman was back in prison. Lopez testified that an attorney delivered handwritten notes from Guzman.

The notes would warn Lopez to be careful about who he talked to, with Guzman advising him, "No one should know where you sleep except you yourself." Guzman had been startled awake by authorities attempting to arrest him days before he was captured in February 2014.

By the end of March of that year, Lopez said he met with Guzman's wife, Coronel, in her home state of Sinaloa, where she relayed a message from Guzman in prison: He "was thinking of taking the risk again to escape from prison" and wanted to know whether Lopez would help.

He said yes.

Lopez said he then met with Guzman's four sons -- Joaquin Jr., Alfredo, Ivan, and Ovidio -- in July 2014 to discuss planning the escape and testified that Coronel would relay messages to the group from Guzman in prison.

Guzman wanted the group to buy him weapons and an armored pickup truck, as well as rent a warehouse near the prison and buy a piece of land nearby.

"The piece of land was because a tunnel had to be built," Lopez testified.

To determine exactly where the tunnel should lead, Lopez said he and Guzman's sons decided to get a watch that could let them know the exact GPS coordinates of Guzman's prison cell.

The group met again -- Guzman wanted to know what progress it had made.

"I dedicated myself to get what had been asked of me," Lopez said. "It wasn't something that you could do overnight, but I was doing my things."

Lopez testified that he was not involved with the digging of the tunnel and that Guzman's sons were handling it.

New details of his escape

At one point, Lopez said Guzman's sons mentioned to him that Guzman was "hearing noises where he was, those who were excavating (the tunnel) were already underneath."

The digging was happening several meters below Guzman's cell, Lopez said, and that noises were coming from the concrete floor.

Guzman escaped from the prison in Altiplano on July 11, 2015.

Guzman wanted to escape on a weekend, when there would be no prison officials around.

JUST WATCHED Homes under fire in the hunt for 'El Chapo' Replay More Videos ... MUST WATCH Homes under fire in the hunt for 'El Chapo' 01:38

Lopez saw Guzman about a week after the 2015 escape. It was then that he learned the details of the escape.

Guzman told Lopez he heard noises of the tunnel being created for months.

"The concrete had been very difficult to break through," Lopez said. "That caused a lot of noise and it was bothering the other inmates, who complained."

Lopez never saw the tunnel himself.

Once Guzman escaped from his cell into the tunnel, a motorcycle with a driver was waiting for him. That driver took him through the tunnel to a piece of land, where an ATV picked him up and drove him to a warehouse. He was then taken to another city, where a pilot and plane were waiting for him. He was flown to a hideout in the mountains of La Tuna, an area in his home state of Sinaloa.

Lopez met with Guzman after his escape in 2015 about eight or nine more times.

The final arrest

Guzman was arrested, again, in January 2016, after a raid by Mexican authorities in which five Guzman associates were killed. He was taken to a different prison in the city of Juarez.

After the arrest, Lopez said that Coronel sought him out for a meeting, where she told him her husband sent his regards and that "he was going to try to make a huge effort to escape again."

Lopez said that he and Coronel "were trying to figure out a way for (Guzman) to go back to Altiplano," the prison from which he had previously escaped.

"She told me that my compadre (Guzman) wanted me to start looking for a piece of land close to the jail," Lopez said.

Lopez testified that he told Coronel he would help but that he didn't have any money.

Lopez testified that another Guzman associate delivered $100,000 to him to help and that he was told he would be given more money, depending on the cost of the land. But Guzman was never moved to the Altiplano prison.

Guzman was eventually extradited to the United States in early 2017.

Lopez was arrested a few months later, in May, in Mexico City and was extradited to the US in 2018. He pleaded guilty to drug trafficking charges and was sentenced to life in prison, but prosecutors may recommend a sentence reduction.

Lopez's family is in the United States "for safety reasons."

Guzman's sons Alfredo and Ivan are under federal indictment on drug-related charges, and the US Treasury Department has sanctioned Ivan and Ovidio under the US Foreign Narcotics Kingpin Designation Act for involvement in drug trafficking activities. CNN was unable to obtain information on the status of Joaquin Guzman.