Five Egyptian diplomats and an embassy employee kidnapped in Tripoli have been released as part of a swap, according to a Libyan government officials.
The release on Sunday comes after Sabaann Hadia, a prominent commander in the rebellion that ousted Muammar Gaddafi, who was arrested in Alexandria, announced his own release on television.
The kidnappings had forced Egypt to evacuate its Tripoli embassy and its Benghazi consulate.
The alleged kidnappers, calling themselves Libyan revolutionaries, had contacted Dubai-based Al Arabiya television channel to demand the release in 24 hours of Hadia, and put one of the Egyptian diplomats on the line.
"The kidnappers have demands and we ask these demands are met and the defendant Abu Hadia be released," a man called Shirbini from the Egyptian cultural centre told the channel.
Hadia is a commander in the Operations Room for Libya Revolutionaries, one of the many armed groups that fought Muammar Gaddafi, Libya's long-time ruler, during the 2011 NATO-backed uprising, but have since refused to disarm and accept Tripoli's authority.
"We won't free the diplomats unless the sheikh is freed within 24 hours," one of the kidnappers said, without giving details of what would happen after that deadline.
A Libyan security official speaking to AFP on condition of anonymity said the kidnappers freed the six as part of a deal between Tripoli and Cairo.
The official said the kidnappers, who have not been identified, demanded the release of Hadia, also known by his nom de guerre Abu Obeida.
But one of the group's leaders, Adel al-Ghariani, told AFP they were not involved in the kidnappings.
The Operations Room for Libya Revolutionaries had formally denied it was involved in the Egyptians' kidnappings, but on Friday it gave warning that there would be a strong response if Hadia was not released.
"What we have been warning the Egyptian authorities about since yesterday is that this kind of response was to be expected because of the security situation in the country," Adel al-Gharyani, a commander, told Reuters news agency.