Mexico’s botched mission to capture an alleged drug-peddling son of narcotics kingpin Joaquin “El Chapo” Guzmán started with an arrest warrant from a federal judge in Washington, DC, his lawyer told The Post on Friday.

Eight people were killed when Mexican agents stormed a home in the country’s drug-infested Sinaloa state Thursday with an arrest warrant for Ovidio Guzman Lopez but abandoned the job when they were outgunned by cartel gunmen.

Lawyer Jeffrey Lichtman, who represented Lopez’s infamous kingpin father, confirmed to The Post that the warrant came out of DC — although he said details of what went down afterward are still murky.

“It’s unclear what exactly happened,” he said, but “Ovidio is safe and not in custody.

“As soon as the smoke clears, we’ll endeavor to figure out exactly what happened here.”

The Mexican national guard released Lopez following his brief capture when it led to an all-out cartel war — sparking wild gun battles throughout Sinaloa which killed eight people and injured another 21.

Guzman Lopez and his brother Joaquin Guzman Lopez were charged with drug trafficking in the US District Court of Columbia in 2017. The indictment was unsealed in February of this year.

Mexico’s president, Andrés Manuel López Obrador, said Friday he backed the decision to let Lopez go free, telling reporters it “was made to protect the citizens.”

Mexico’s defense secretary decried the botched operation by the country’s army and national guard, which he said was meant to pave the way for US extradition. He said Mexican cabinet officials were not made aware of it beforehand.

“The group responsible for this action, in eagerness to achieve positive results, acted in a hasty manner, with poor planning,” Secretary of Defense Luis Cresencio Sandoval told reporters in Culiacan on Friday.

In July, a Brooklyn federal judge sentenced El Chapo — the once-powerful leader of the Sinaloa cartel — to life in prison after he was convicted on a slew of drug-trafficking charges.