Saif al Islam Gaddafi was captured by a Libyan militia late in 2011, the year when a popular uprising toppled his father, Muammar Gaddafi, after more than 40 years in power.
Saif al Islam, the son of the late Libyan leader Muammar Gaddafi, has been released after more than five years in detention.
The Abu Bakr al Sadiq Brigade, a militia of former rebels that controls the town of Zintan in western Libya, said it had freed Saif al Islam on Friday evening, "the 14th day of the month of Ramadan", under an amnesty law promulgated by the parliament based in the east.
"We have decided to liberate Saif al Islam Muammar Qaddafi. He is now free and has left the city of Zintan," a statement by the group said.
The parliament in the city of Tobruk is part of one of three rival administrations in Libya, evidence of the chaos that has prevailed in the country since Muammar Gaddafi's ouster and death.
Saif al Islam was captured by the Abu Bakr al Sadiq Brigade fighters late in 2011, the year when a popular uprising toppled Gaddafi after more than 40 years in power. He was later killed.
The uprising later plunged the oil-rich North African nation into a civil war in which Saif al Islam led Gaddafi's loyalist forces against the rebels.
Rival groups and militias have been vying for control of Libya ever since, with the authorities in the east not recognising the UN-backed Government of National Accord (GNA) based in the capital.
The city of Zintan, where Saif al Islam was being held, is controlled by armed groups opposed to the GNA.
Gaddafi's son is the subject of an arrest warrant for crimes against humanity allegedly committed during the eight months of the uprising in 2011.
Libya's authorities and the International Criminal Court (ICC) are in dispute over who has the right to judge him.
He was sentenced to death in July 2015 by a court in Tripoli for his role in the repression of the 2011 revolt.
In July 2016, his lawyers claimed that their client had been released under an amnesty issued by the unrecognised authorities in the east of the country.
But the GNA said the amnesty, enacted in April that year, cannot apply to persons accused of crimes against humanity.