Ovidio Guzmán López, a son of Joaquín Guzmán Loera, the Mexican drug lord known as El Chapo, was captured northwest of Mexico City on Thursday, but was freed after police came under heavy fire from cartel fighters, authorities said.

The police operation set off violent gunbattles across the city of Culiacán in Sinaloa state, home to the murderous Sinaloa cartel, which El Chapo ran for decades before he was finally imprisoned in the United States.

Download the NBC News app for breaking news

Choking smoke poured into the air and gunfire could be heard for hours as word spread of the discovery of El Chapo's son, Guzmán López. Vehicles and a gas station were set on fire while cartel gunmen roamed the city in trucks, at least one of which was armed with a mounted machine gun, videos posted on social media showed.

Mexico's president Friday defended the decision to release Guzmán López, saying it saved lives.

"The capture of one criminal cannot be worth more than the lives of people," President Andrés Manuel López Obrador said, according to The Associated Press. "This decision was made to protect citizens. ... You cannot fight fire with fire."

López Obrador, a leftist who took office in December, has said the anti-crime approaches of previous governments turned Mexico into a “graveyard.”

Mexican Security Minister Alfonso Durazo, appearing next to the president, said: "We will pacify the country without using violence, without repression."

Durazo confirmed previously that Guzmán López was among four men who were discovered by a defense and National Guard contingent after it was attacked while on patrol in Culiacán.

Mensaje del Gabinete de Seguridad sobre los hechos suscitados en Culiacán, Sinaloa: pic.twitter.com/gQ0pwrryr0 — Secretaría de Seguridad y Protección Ciudadana (@SSPCMexico) October 18, 2019

But the patrol was quickly outmatched by cartel gunmen and was withdrawn to prevent lives being lost, the government said.

"The decision was taken to retreat from the house, without Guzmán, to try to avoid more violence in the area and preserve the lives of our personnel and recover calm in the city," Durazo said.

José Luis González Meza, a lawyer for El Chapo's family, told the AP that the family said, "Ovidio is alive and free."

State security officials told Telemundo, NBC's Spanish-language network, that 30 to 40 inmates escaped from Aguaruto prison in Culiacán during the mayhem.

Guzmán López, who is believed to be 28 or 29, is wanted in the U.S. following his indictment with his brother Joaquín on federal drug conspiracy charges in February.

Prosecutors said the brothers conspired to distribute cocaine, methamphetamine and marijuana in the U.S. from 2008 to 2018. American authorities have said Guzmán López fought to seize control of the Sinaloa cartel after his father was extradited to the U.S. in 2017.

El Chapo was sentenced to life in prison plus 30 years in July after he was convicted on multiple federal charges in February.

Federal jurors in New York City agreed with prosecutors that El Chapo led an organization that smuggled at least 200 tons of cocaine into the U.S. over more than 25 years.

They found the Sinaloa Cartel leader guilty on 10 charges, including engaging in a continuing criminal enterprise and multiple counts of distributing large amounts of narcotics internationally.