Mexican officials cut loose the arrested son of notorious drug lord Joaquin “El Chapo” Guzman on Thursday “to protect lives” after cartel gunman turned the Mexican city where he was collared into an urban war zone, authorities said.

Ovidio Guzman López, who is wanted in the US on drug-trafficking charges, was detained by Mexican national guard and army troops, who raided a house in Culiacán where he was staying, according to Mexican security secretary Alfonso Durazo.

As word spread of Guzman Lopez’s capture Thursday afternoon, intense gun battles broke out between cartel gunmen — armed with military-grade weapons — and Mexican authorities.

Cartel thugs torched cars and buses and left their burned-out remains blocking main roads in and out of the city. Other roads were shut by the army, according to local reports.

Images shared on Twitter show masked gunmen manning a machine gun mounted on the back of a truck on Culiacán streets. Other gunmen loyal to the cartel fired .50-caliber sniper rifles from the backs of trucks.

Meanwhile, heavily armed gunmen who had a “greater force” than the government troops surrounded the house where Guzman Lopez was being held — so officials released him, knowing they were outmatched, Durazo said.

“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,” Durazo said.

A lawyer for Guzman Lopez gave a television interview after his release, praising the move.

“Thank God, Ovidio has appeared,” lawyer José Luis Gonzalez Meza said, according to the Wall Street Journal. “He is free.”

In January, a Brooklyn federal judge sentenced El Chapo to life in prison, which opened up a power vacuum in the cartel once considered the most prolific drug-dealing outfit in the world.

Prosecutors in El Chapo’s trial said last year that his “favorite” sons, Ivan and Alfredo, had stepped in to fill their father’s shoes.

With Post wires