A federal judge in New York has granted the US government's request to dismiss the charges against a Mexican ex-minister accused of drug trafficking.
Gen Salvador Cienfuegos, who was Mexico's defence minister from 2012 to 2018, was arrested at Los Angeles airport last month.
Prosecutors said he had links to the "extremely violent" H-2 drug cartel.
But following pressure from Mexico, the US Department of Justice said he should be investigated in his home country.
In a hearing on Wednesday a US federal judge granted the Department of Justice's (DoJ) request.
The prosecutor's office said that it had a strong case against Gen Cienfuegos but that maintaining cooperation between US and Mexican law enforcement authorities was more important than prosecuting the ex-defence minister.
The Mexican government, which had not been informed of the investigation against Gen Cienfuegos, had threatened to "revise" its relationship with the US Drug Enforcement Administration.
Gen Cienfuegos arrived back in Mexico on Wednesday after the judge dropped the charges.
Who is Salvador Cienfuegos?
Gen Cienfuegos was defence minister during the administration of President Enrique Peña Nieto. In that role he not only ran the Mexican army but also reported directly to the president on all matters pertaining to the country's security.
In Mexico, the armed forces not only deal with outside threats to the country but also play a key role in fighting the country's powerful drug cartels.
The army was first deployed to fight the cartels in 2006 by then-President Felipe Calderón, who declared "war" on them.
But it was while Gen Cienfuegos was defence minister that the military's role in law enforcement was enshrined in law. The "internal security law" was later overturned by the Supreme Court, which ruled that it was unconstitutional for the military to have a role in domestic security.
But with the police poorly trained and equipped, the military has continued to be the key player in Mexico's battle against the cartels.
During his time as defence minister Gen Cienfuegos - who is now 72 and who retired two years ago - portrayed himself as a relentless enemy of the drug cartels, whose members he described as "criminal beasts".
Why is he in the news?
Gen Cienfuegos hit the headlines when he was arrested at Los Angeles airport on 15 October.
He is not the first high-ranking former Mexican official to be arrested on drugs charges. In December 2019, Mexico's former security minister, Genaro García Luna, was arrested in Texas accused of taking bribes from a drugs cartel.
But the detention of Gen Cienfuegos caused waves for two reasons - it cast a cloud over the military, which many regarded as less corrupt than the underfunded police, and it came as a complete surprise to the Mexican government and even some US officials.
What were the charges against him?
The indictment accused Gen Cienfuegos, who allegedly was known as "El Padrino" (The Godfather), of trafficking drugs to the US and laundering money during his time as defence minister.
More damagingly, he was also accused of permitting "the H-2 Cartel - a cartel that routinely engaged in wholesale torture and murder - to operate with impunity in Mexico".
Investigators alleged that not only had he shielded members of the H-2 cartel but that he had also used the Mexican military to launch operations against H-2's rivals.
Gen Cienfuegos pleaded not guilty to the charges last month.
Why are the charges being dropped?
US Attorney General William Barr and his Mexican counterpart, Alejandro Gertz, issued a joint statement on Tuesday saying that "the US Department of Justice has made the decision to seek dismissal of the US criminal charges against former Secretary Cienfuegos, so that he may be investigated and, if appropriate, charged, under Mexican law".
It said the US had taken the decision to seek dismissal of charges "in recognition of the strong law enforcement partnership between Mexico and the United States, and in the interests of demonstrating our united front against all forms of criminality".
A court filing seeking the dismissal of the charges stated that "sensitive and important foreign policy considerations outweigh the government's interest in pursuing the prosecution of the defendant... and therefore require dismissal of the case".
What's behind the move?
The arrest of Gen Cienfuegos infuriated Mexican President Andrés Manuel López Obrador, who appeared particularly riled by the fact that Mexican officials had not been informed about the investigation into the general and his administration was caught by surprise by his arrest.
According to Mexican weekly magazine Proceso, the secrecy surrounding Gen Cienfuegos' arrest angered the Mexican administration so much that they planned to "revise" their relationship with the US Drug Enforcement Administration (DEA).
In an interview with Proceso, Foreign Minister Marcelo Ebrard said that "there will be co-operation, but it will be on a different basis, everything will be different".
Reuters news agency reported that US Attorney General William Barr spoke to Mr Ebrard in early November to try to ease the bilateral tensions triggered by Gen Cienfuegos' arrest.
The reference to "sensitive foreign policy considerations", stated by prosecutors as a reason for dismissing the case, seems to suggest Mr Barr thought that Mexico's co-operation with the DEA trumped the US's interest in pursuing the case against Gen Cienfuegos.
What happens next?
The US Department of Justice says that it has provided Mexico with "evidence in this case and commits to continued cooperation... to support the investigation by Mexican authorities".
Mr Ebrard says that Gen Cienfuegos will be returned to Mexico in the custody of US marshals but that, upon his arrival, he will be treated as a normal citizen as there is no warrant for his arrest in Mexico.
An investigation is already under way but it will be up to Mexico's Attorney General's Office to determine whether he is charged under Mexican law.
Many commentators in Mexico have questioned whether Gen Cienfuegos will be charged, especially considering how much the administration of President Andrés Manuel López Obrador relies on the military after his plans for a new National Guard failed to take off.
But Mr Ebrard dismissed those concerns arguing, like President López Obrador has done, that Gen Cienfuegos' return to Mexico is a question of sovereignty: "We do not see this as a path to impunity, but rather as an act of respect for Mexico and the Mexican armed forces."