Fighting raged for several hours after Ovidio Guzmán López was found during a routine patrol in the city of Culiacán.
Footage showed heavily-armed men firing on police, with cars, bodies and burning barricades 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 (AP): "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 them.
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. But he is not one of El Chapo's best-known sons.
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.
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".
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.