Colombia's former intelligence chief has been released from prison following an appeals court ruling, which said he had been wrongly jailed last month.
Mr Noguera quit in October but has denied any wrongdoing
The court found that the prosecutor who had ordered Jorge Noguera's arrest lacked the authority to do so.
Mr Noguera had been charged with collaborating with right-wing paramilitary groups, but denies this.
As he was released, Mr Noguera said the ruling had given him renewed confidence in the judicial system.
Jorge Noguera, the former head of the Department of Administrative Security (DAS), was jailed in February for conspiring with paramilitary groups, who are blamed for some of the worst massacres in Colombia's civil war.
On Friday, a judge ruled that the ex-spy chief was being "illegally and unconstitutionally" detained because the chief prosecutor had not personally issued the warrant for his arrest.
Only the chief prosecutor could seek Mr Noguera's arrest because of the latter's public servant status when he allegedly committed the crimes, the judge said.
Jorge Noguera resigned as head of the Administrative Security Department (DAS) in October 2006.
He was arrested after being questioned about supplying the names of unionists and rights workers to right-wing militias. A number of people on the alleged hit-list were murdered.
Mr Noguera was a close ally of President Alvaro Uribe, who was re-elected last year and has been popular for reducing crime.
He has backed a clampdown on leftist militias and overseen the disbanding of thousands of right-wing paramilitaries.
The right-wing militias were formed in the 1980s to fight Marxist guerrillas but both sides have been involved in the cocaine trade.
Tens of thousands of civilians are known to have died in the 40-year conflict between the state and left-wing rebels.