* Powerful militia denies involvement in abductions
* Egyptian authorities in talks to free diplomats
* Security deteriorating, two years after revolution
By Ghaith Shennib
TRIPOLI, Jan 25 (Reuters) - Five Egyptian embassy staff kidnapped in Tripoli were abducted in retaliation for the arrest of a Libyan militia commander by Egyptian authorities, the Libyan government said on Saturday.
Four diplomatic staff were snatched in Tripoli on Saturday, including the cultural attache, and gunmen kidnapped another on Friday, forcing Cairo to evacuate its embassy and Benghazi consulate as a precautionary measure.
The kidnappings underlined Libya's instability two years after Muammar Gaddafi's fall, with heavily-armed former rebels and Islamist militants who fought in the uprising still challenging state authority.
No group claimed responsibility, but the Islamist-leaning Operations Room for Libya Revolutionaries, one of the many militias that fought Gaddafi in the NATO-backed uprising, reported its commander had been arrested in Egypt.
The Operations Room, a group of Islamist-leaning former rebel fighters nominally hired by the government to secure Tripoli, was accused of briefly abducting Libya's Prime Minister Ali Zeidan in October last year.
Libya's Justice Minister Salah al-Marghani said the government had made contacts with the kidnappers to free the diplomats, but he said they had been taken in tit-for-tat 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."
The Operations Room of Libya's Revolutionaries militia denied involvement. But it said on Friday Hadia had been arrested in Egypt, where he had been travelling with his family for medical treatment.
Al Arabiya channel spoke by telephone to a man claiming to be one of the kidnappers, who said they were Libyan revolutionaries and demanded to speak immediately to the commander.
"We won't free the diplomats unless the sheikh is freed within 24 hours," he said.
Egyptian state news agency MENA said one diplomat had earlier called his embassy to say he was being "treated well".
Egypt's foreign ministry spokesman told Al Arabiya that the embassy in Tripoli and the consulate in Benghazi were temporarily evacuated as a precautionary measure. He confirmed Hadia was under investigation in Egypt.
"If there is no charge at the end of it then he will be released," he said. "He will be treated kindly and we expect good treatment of the Egyptians."
The Operation Room's commanders 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 is one of the scores of militia groups who battled Gaddafi's forces in 2011 to topple the long-running leader. Since his fall, rival militias and former rebels have fought turf wars and often used their military muscle to make demands on the government.
When armed gunmen snatched the prime minister from his luxury hotel room in Tripoli in October, the Operations Room claimed it had arrested Zeidan. They later denied they were involved, when he was released after several hours.
Zeidan, a liberal, had 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.
Libya's General National Congress is split between the Islamist JCP party, political wing of the Muslim Brotherhood, and the nationalist National Forces Alliances. Some former rebel brigades are allied to various political factions.
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.