Mexico's president has defended freeing drug kingpin Joaquín "El Chapo" Guzmán's son soon after his arrest.
When Ovidio Guzmán López was seized at a house on a judge's warrant in the city of Culiacán, cartel gunmen fought street battles with security forces.
At least eight people were killed and 16 wounded, the authorities say, with vehicles left burning in the streets.
President Andrés Manuel López Obrador said the decision to cancel the arrest on Thursday had saved lives.
Senior security officials had decided on his release, the president said at a news conference. "The officials who took this decision did well," he said.
"The capture of a criminal is not worth more than people's lives."
A lawyer for the Guzmán family appeared before journalists and described the president as "human" and "Christian". He had decided "not to cause Ovidio harm", José Luis González Meza said.
There was no negotiation to free him, he added.
Mr López Obrador was elected on a platform of cracking down on Mexico's drug cartels, and has tasked the National Guard, a new security force, with fighting the dealers.
Under El Chapo's leadership, the Sinaloa cartel was the biggest supplier of drugs to the US, officials say.
The kingpin was jailed earlier this year, and Ovidio Guzmán López is one of several brothers with a hand in running the cartel.
Thought to be in his twenties, he is accused of drug trafficking in the US.
What happened in Culiacán?
A patrol of National Guard militarised police came under intense fire from a house on Thursday afternoon, Security Minister Alfonso Durazo said.
The security forces fought back and found Mr Guzmán, but were then surrounded by gunmen and forced to retreat.
Defence Minister Luis Cresencio Sandoval told reporters the operation had been "badly planned".
Five cartel members and a National Guard policeman are among the dead, he said.
Fighters also attacked security forces in other parts of Culiacán and bodies were seen on the streets.
Witnesses described scenes of panic in the city, a stronghold of the Sinaloa cartel, as families with small children fled from gunfire.
Footage on social media showed a pick-up truck with a machine gun mounted on the back, in scenes reminiscent of a war zone.
Fifty-one inmates escaped from Aguaruto prison during the disorder.
Other footage showed families scrambling to take cover under cars and in shops as bullets flew. In one video, a girl asked her father: "Why are they shooting bullets?"
A purported mugshot taken of Mr Guzmán while he was detained by police was shared widely on social media.
Ovidio Guzmán Lopez released. From a PR standpoint alone, this was a total disaster – the slow drip of info, the photos of Guzmán in custody, the government statement… just terrifying how badly authorities handled it pic.twitter.com/syJwtPQHGy— Stephen Woodman (@Stephentwoodman) October 18, 2019
A source of great embarrassment
By Juan Carlos Perez Salazar, BBC Mundo
It seems that, for a while, Ovidio "The Mouse" Guzmán was in the hands of police.
What followed next, though a source of great embarrassment for the Mexican government, may not be surprising to those who know how powerful drug cartels are in parts of the country.
Culiacán is one of those areas. It has been linked with the production of drugs since at least the 1940s, and several of the biggest "capos" (drug lords) were born there. Despite the capture of El Chapo, its most well-known leader, the Sinaloa Cartel is still immensely powerful in the region.
And for critics of Mexico's president, this lays bare the failure of his strategy against the drug cartels. Some even say he has no strategy at all.
What was El Chapo's role in Mexico's drug trade?
"El Chapo" (or "Shorty") ran the Sinaloa cartel across northern Mexico.
Over time, it became one of the biggest traffickers of drugs to the US. El Chapo escaped a Mexican jail through a tunnel in 2015, but was later arrested. He was extradited to the United States in 2017.
He was accused of having helped export hundreds of tonnes of cocaine into the US and of conspiring to manufacture and distribute heroin, methamphetamine and marijuana.
El Chapo, 62, was found guilty in New York of 10 charges, including drug trafficking and money laundering.
Who are 'El Chapo's' children?
Guzmán has been married three times. Estimates of the number of offspring, from wives and girlfriends, vary from eight to 15.
Ovidio Guzmán López is thought to be one of four children born to the drug kingpin's second wife, Griselda Lopez Perez.
More prominent are his older brothers by Guzmán's first marriage to Maria Alejandrina Salazar Hernández- Ivan Archivaldo Guzmán Salazar and Jesús Alfredo Guzmán Salazar, both 36.
Ivan Archivaldo has developed a reputation for an extravagant lifestyle and flaunting his wealth on social media.
The jailing of "El Chapo" threw up the question of who should now lead the Sinaloa cartel.
There are reports of infighting between some of the Guzmán sons, known as "los chapitos", and the co-founder of the Sinaloa cartel, Ismael "El Mayo" Zambada.
Zambada has been trying to oust the sons, VICE news reported in July, quoting sources in the mountains of Sinaloa state. Gunmen are said to have been defecting to work for Zambada.
Jesús Alfredo is wanted in the US on allegations of drug-trafficking and is on the most-wanted list of US Drug Enforcement Administration.
Ivan Archivaldo has also been charged by the US authorities.