Heavy fighting broke out in northern Mexico on Thursday after security forces detained a son of the jailed drug kingpin Joaquín "El Chapo" Guzmán.
Fighting raged for hours after Ovidio Guzmán López was found in what authorities said was a routine patrol in the city of Culiacán.
Armed men were seen firing on police with bodies strewn in the road.
Police withdrew without Mr Guzmán in their custody to avoid further violence, officials said.
Mexico's security minister, Alfonso Durazo, told Reuters news agency that a patrol of National Guard militarised police came under intense fire from outside the house where they had located Mr Guzmán, forcing them to retreat from the building for their own safety and "to recover calm in the city".
A lawyer for the Guzmán family told the Associated Press, "Ovidio is alive and free."
Mexico's President Andrés Manuel López Obrador said he would hold a meeting of his security cabinet to discuss the incident.
Mr López Obrador was elected on a platform of cracking down on Mexico's drug cartels, and has tasked a new security force, the National Guard, with fighting the dealers.
Under El Chapo's leadership, the Sinaloa cartel was the biggest supplier of drugs to the US, officials say. With the kingpin now behind bars, the cartel is said to be partially controlled by Ovidio Guzmán Lopez, who is accused of drug trafficking in the US and believed to be in his twenties.
What happened in Culiacán?
The state government said Mr Guzmán was found in a house by a police patrol on a routine search. It said cartel members subsequently launched the huge attack in an attempt to seize him back from the authorities. Fighters also attacked security forces in other parts of Culiacán.
Witnesses described scenes of panic in the city, a stronghold for the Sinaloa cartel, as families with small children fled from gunfire.
"No one knows what is going on but everyone is afraid and they have told us to not come in to work tomorrow," Ricardo González, a city resident, told AP.
Footage on social media showed a pick-up truck with a machine gun mounted on the back, in scenes reminiscent of a war zone.
Other footage showed families scrambling to take cover under cars and in shops as gunfire roared. 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
Sinaloa state's head of security, Cristobal Castañeda, told the Televisa network that two people had been killed and 21 injured, according to preliminary information.
Pictures showing what appeared to be dead bodies on the streets suggest the death toll could rise.
Some police officers were wounded, local officials said, but would not provide further details.
As fighting brought the city to a standstill, the Sinaloa state government said an unknown number of inmates had escaped from the Aguaruto prison.
It said it was "working to restore calm and order" and called on residents to "remain calm, stay off the streets and be very attentive to official advisories on the evolving situation".
A source of great embarrassment
By Juan Carlos Perez Salazar, BBC Mundo
The details of what happened in Culiacán are still sketchy, but 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, capital of the state of Sinaloa, 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. He 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 off-spring, 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 Hernandez - Ivan Archivaldo Guzman Salazar and Jesus Alfredo Guzman 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 Guzman 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.
Jesus 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.