It was a scene of jubilation outside the Abu Selim prison
Libya has released 88 Islamist inmates, some of them belonging to a group with suspected links to al-Qaeda, the country's state-run charity has said.
It said among those freed were 45 members of the Libyan Islamic Fighting Group, which had been accused of trying to oust Col Muammar Gaddafi's regime.
The militants had been in prolonged talks with Tripoli to reach a deal to renounce violence and win the release.
They were freed from the notorious Abu Selim prison, near Tripoli.
"We congratulate all advocates of human rights issues on the release of 45 members of the Libyan Islamic Fighting Group and 43 members of various other Jihadist groups," Libya's Human Rights Association said in a statement on Thursday.
The association is part of the powerful Gaddafi Foundation, which is run by Col Gaddafi's son, Saif al-Islam.
The move is seen as yet another step in Libya's national reconciliation agenda, the BBC's Rana Jawad says.
The Human Rights Association also welcomed what it said was a decision to demolish the Abu Selim prison - the scene of riots in 1996 in which an unknown number of people were killed.
However, it did not provide any details about the closure.