Former student leader Lorent Saleh put on flight to Madrid days after anti-government politician died in state custody.

Venezuelan authorities have freed a prominent opposition activist jailed for four years just days after an anti-government politician died in state custody.

Lorent Saleh, 30, was immediately escorted to the airport on Friday and put on a flight to Madrid with Spanish government officials.

Upon arriving at Madrid's airport Saturday, Saleh told the media and a small group of exuberant Venezuelan opposition supporters that "the fight goes on".

"What I ask is that we all think about the fact that in Venezuela there are innocent people behind bars, people that have been kidnapped and who deserve to cross the same bridge that I have," Saleh said.

Saleh said that he did not know he was being released until the last minute.

"They had already put me in a police car and we were heading to the airport when they told me," Saleh said.

"Today, I have been able to see the sunrise for the first time in four years, and I am still coming to grips with that."

His release came just days after Fernando Alban, a Caracas city council member accused of taking part in a failed drone attack on President Nicolas Maduro, died in pretrial detention, an incident that sparked international outrage.

Authorities say the 52-year-old committed suicide by jumping out of a 10th-floor window of the state intelligence service headquarters. But his supporters and family say he was tortured to death and then thrown out.

Several foreign governments and the United Nations have called for an independent investigation to determine whether foul play was involved.

'Correct decision'

A government truth commission said Saleh was at risk of causing harm to himself after being evaluated for suicidal tendencies while imprisoned. It said he should be released as part of efforts to ease political tensions in the South American nation.

Saleh was arrested in Colombia in 2014 after he appeared on a video phone call leaked by Venezuelan authorities bragging to an unknown person about plans to hire sharpshooters to sow unrest in Venezuela and was extradited.