Four Egyptian embassy staff were kidnapped in Tripoli on Saturday (local time), a day after the abduction of another Egyptian diplomat, in what Libya's government called a reaction to Egypt's arrest of a Libyan militia commander.
No group claimed responsibility for any of the abductions, but they came soon after a powerful Islamist-leaning militia group reported its commander had been arrested in Egypt and warned of a response unless he was freed.
Two years after Muammar Gaddafi's overthrow, Libya remains in flux, with the government struggling to rein in heavily-armed former rebels, militias and Islamist militants who fought in the uprising but often challenge central authority.
Libya's Justice Minister Salah al-Marghani said the government had made contacts to free the diplomats, who he said had been taken in reaction to Cairo's arrest of militia commander Shaban Hadia.
"We condemn and reject what has happened here as a reaction," he told reporters.
"Those who are detaining the Egyptian diplomats committed a huge mistake, for themselves and for Libya."
Egyptian state news agency MENA said the first diplomat had called his embassy to say he was being "treated well".
Marghani did not accuse any group. But the Operations Room of Libya's Revolutionaries militia said on Friday Hadia had been arrested in Egypt, where he had been travelling with his family for medical treatment.
The group's commanders denied involvement in the kidnappings because they operate nominally under the command of Libya's military chief of staff. On Friday they initially warned Egypt of a "strong response" unless Hadia was freed.
"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," commander Adel al-Gharyani told Reuters.
The Operations Room, a group of Islamist-leaning former rebel fighters hired by the government after Gaddafi's fall to provide security in Tripoli, was accused of briefly abducting Libya's Prime Minister Ali Zeidan last year.
Zeidan, a liberal, upset Libyan Islamists last year when he visited Egyptian chief of staff General Abdel Fattah al-Sisi after the military deposed Egypt's Islamist president, Mohamed Mursi, following protests against his rule.
A number of foreigners have been abducted and attacked in Libya in recent weeks. Security forces in Tripoli earlier this week freed a South Korean trade official held for days by kidnappers who officials said were not politically motivated.
An American teacher was shot dead in Benghazi in December, and in January a British man and a New Zealand woman were killed on a beach in western Libya.