A Spanish court has rejected an extradition request for Venezuela’s former intelligence chief General Hugo Carvajal.
The US sought his extradition, accusing him of drug trafficking offences.
He turned against the government of President Nicolás Maduro in February and backed opposition leader Juan Guaidó as Venezuela’s leader.
Mr Carvajal fled Venezuela on a boat and was arrested in Madrid in April.
On Monday he was pictured with his family as he left a prison in Spain.
- Venezuelan ex-spy chief arrested in Spain
- Venezuela reveals ‘months of secret talks’ with US
He had been under US sanctions since 2008 due to allegations he helped Columbia’s Farc rebel group and protected US-bound drug shipments.
Federal charges which accuse him of co-ordinating a 5,600kg (12,345lb) shipment of cocaine from Venezuela to Mexico in 2006, became public in 2014.
The US Justice Department said in April that if convicted, he could face between 10 years and life in prison.
Washington also believes that Mr Carvajal could share incriminating evidence about Mr Maduro.
Mr Carvajal was a close ally of Venezuela’s late socialist leader Hugo Chávez but later denounced his successor President Maduro. He was stripped of his rank after choosing to back opposition leader Juan Guaidó.
Mr Guaidó declared himself president in January, citing Venezuela’s constitution. He has the backing of dozens of countries including the US.
Mr Carvajal escaped Venezuela by boat to the Dominican Republic before travelling on to Spain.
This was not the first time he had faced extradition to the US. In 2014 he was arrested on drug trafficking charges on the Dutch Caribbean island of Aruba. However he was freed after the extradition request was denied.