Five Egyptian embassy staff who were kidnapped in the Libyan capital Tripoli have been freed, Libyan officials say.
The country's deputy foreign minister, Razak Grady, said three diplomats had been released and the others were being handed over to the authorities.
Four Egyptian officials were snatched from their homes on Saturday with another seized on Friday.
Egypt freed Libyan militia commander Shabaan Hadiya after the release of its embassy staff.
However, Egyptian and Libyan government sources denied that Mr Hadiya's release was part of a deal with the hostage-takers, Reuters news agency reports.
Mr Hadiya, head of the Libya Revolutionaries' Operation Room (LROR), was arrested in the Egyptian city of Alexandria on Friday.
It is unclear why he was arrested.
Cairo evacuated its diplomatic missions in Tripoli and Benghazi following the abductions.
"I can confirm that three of the Egyptian embassy staff are home and the rest are in the process of being transferred to the custody of state authorities," Mr Grady told the BBC.
"They are healthy, they have been treated well."
He said that the men were being held outside of Tripoli, but gave no further details.
Their successful release showed that the Libyan authorities were rebuilding the country's stability, he added.
"I think the fact they have been released… despite the challenges we are facing, it shows we are able to bring this to a peaceful end."
Libyan government officials blamed the LROR - one of the militias that emerged during uprising against Muammar Gaddafi - for the brief abduction of Prime Minister Ali Zeidan in October 2013.
Among the Egyptian embassy staff seized in Tripoli was the cultural attache.
Kidnappers on Saturday called Dubai-based television channel Al Arabiya, demanding Mr Hadiya's release. One of the Egyptian diplomats was put on the line to call on Cairo to respond to the demands.
Several kidnappings of officials in Libya recently have been blamed on militias.
They are often paid by the government, but their allegiance and who controls them remain in doubt.