Heavily armed fighters surrounded security forces in a Mexican city and made them release one of drug lord Joaquin 'El Chapo' Guzman's sons after his capture triggered gun battles and a prison break that sent civilians scurrying for cover.

Security Minister Alfonso Durazo said a patrol by National Guard militarised police first came under attack from within a house in the city of Culiacan, 1,235km northwest of Mexico City.

After entering the house, they found four men, including Ovidio Guzman, who is accused of drug trafficking in the United States.

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

Simultaneously, fighters swarmed through the city, battling police and soldiers in broad daylight.

They torched vehicles and left at least one petrol station a blaze.

Mr Durazo told Reuters: "The decision was taken to retreat from the house, without Guzman, to try to avoid more violence in the area and preserve the lives of our personnel and recover calm in the city." 

The reaction to Guzman's capture was on a scale rarely seen during Mexico's long drug war, even after his more famous father's arrests.

The chaos continued as night fell, with a large group of inmates escaping from the city prison.

Residents cowered in shopping centres and supermarkets as gunfire roared. Black plumes of smoke rose across the skyline.

Families with young children left their cars and lay flat on the road. Bullets cracked up ahead. 

"Dad, can we get up now?" a small boy said to his father in a video posted on Twitter.

"No, stay there on the floor," the man replied, his voice trembling.

Cristobal Castaneda, head of security in Sinaloa, told the Televisa network that two people had been killed and 21 injured, according to preliminary information. 

He said police had come under attack when they approached roadblocks manned by gunmen. He advised residents not to leave their homes.

It was not immediately clear if members of the patrol were harmed in the standoff. 

Reuters TV showed scenes of at least three bodies lying next to cars on the street.

The chaos in Culiacan, long a stronghold for the Guzmans' Sinaloa cartel, will increase pressure on President Andres Manuel Lopez Obrador, who took office in December promising to pacify a country weary after more than a decade of a drug war. 

Murders this year are set to be at a record high.

Yesterday's events follow the massacre of more than a dozen police in western Mexico earlier this week, and the killing of 14 suspected gangsters by the army a day later.