* Algeria pulls diplomatic staff out from Tripoli
* Foreign diplomatic staff targeted in tit-for-tat abductions
* Libya forces struggle to impose security, control militias (Adds byline details on evacuation, background on diplomats)
By Lamine Chikhi
ALGIERS, May 16 (Reuters) - Algeria sent a team of special forces to evacuate its ambassador and embassy staff from Libya in a military plane after a militant threat to its embassy, officials and a security source said on Friday.
Algeria gave few details on the threat, but security in Libya has deteriorated and at least eight foreign diplomats have been abducted in Libya this year by militants seeking to exchange hostages for fighters detained overseas.
"Due to a real and imminent threat targeting our diplomats the decision was taken in coordination with Libyan authorities to urgently close our embassy and consulate general temporarily in Tripoli," the foreign ministry in Algiers said in a statement.
The security source said the midnight operation on Thursday involved a team of Algerian special forces who arrived in Tripoli to escort the diplomats out of Libya. The threat was from al Qaeda, the source said, adding that the ambassador and staff had all now been evacuated.
Since the 2011 uprising that ousted Muammar Gaddafi, Libya's central government has been fragile and unable to impose its authority on brigades of heavily armed former rebels and Islamist militants.
With its own troops still in training, Libya's army is no match for militias who have taken over oil facilities, stormed parliament and last year even kidnapped a prime minister from a Tripoli hotel to make demands on the state.
Jordan's ambassador was kidnapped last month by gunmen who wanted an Islamist militant to be released. He was freed on Tuesday after Amman released the Libyan who had been serving a life sentence in jail for an attempted airport bombing.
Libyan Islamists have also seized two Tunisian diplomats to demand the release of fellow militants jailed in Tunisia for attacking security forces there in 2011, according to the Tunisian government.
Earlier this year, gunmen kidnapped five Egyptian diplomats in 24 hours to demand the release of a top Libyan militia commander who had been detained by Egyptian authorities. He was let go and they were freed.
Algeria is particularly sensitive to Islamist militant threats after its decade-long war in the 1990s with armed Islamists that killed more than 200,000 people.
"This is a very worrying signal that confirms that Algeria is al Qaeda top target.., and that Libya is now a land of militants," Algerian security analyst Khalifa Rekibi said.
Al Qaeda in the Islamic Maghreb and other militant groups are still active in Algeria, mainly in the south, where Algerian officials are concerned about the spillover from Libya's security turmoil across the border.
Six Algerian diplomats were kidnapped in Mali in 2012 by the Islamist militant group MUJAO, which claimed later to have killed one of the diplomats, though that has not been confirmed by Algerian authorities. The group is believed still to be holding the others. (Reporting by Lamine Chikhi; writing by Patrick Markey)