WASHINGTON : Four US military personnel have been released after being detained briefly by the Libyan govt, the US State Department said on Saturday. State Department spokeswoman Jen Psaki, who hours earlier had announced the Americans' detention, did not say why they were held. "All four US military personnel being held in Libyan government custody have been released," Psaki said in a statement just after midnight. "We are still trying to ascertain the facts of the incident." According to Psaki, the four "were operating in an area near Sabratha as part of security preparedness efforts when they were taken into custody." Sabratha, known for its Roman ruins, is located some 65kmswest of the capital Tripoli. "We value our relationship with the new Libya," Psaki said. "We have a strategic partnership based on shared interests and our strong support for Libya's historic democratic transition." A US official,speaking on condition of anonymity, told AFP that the four were released just two hours after the US State Department announced their detention.

The military staff were attached to the security team at the US embassy in Tripoli and may have been scouting escape routes for possible future use by diplomats, The New York Times reported, citing unnamed US officials. The personnel were detained at a checkpoint and moved to the interior ministry, according to the Times. Americans in Libya have been targeted more than once since 2011, when the regime of strongman Moamer Kadhafi was overthrown by local rebel groups backed by US and NATO airpower. In September 2012 four people, including the US ambassador to Libya, were killed in an attack on the US consulate in the eastern city of Benghazi by Islamist gunmen with alleged Al-Qaeda ties.

Ambassador Christopher Stevens, a popular diplomat and fluent Arabic speaker, was the first US ambassador killed while on duty in three decades. In mid-November, the State Department revealed that since January it has been quietly offering a $10 million (7.3 million euro) reward to help track down the militants behind the attack. Libya has been struggling to integrate the rebel groups that helped topple the Kadhafi regime into the regular armed forces. Militias have carved out their own fiefdoms, each with its own ideology and regional allegiances.

The vast, mostly desert country is effectively ruled by a patchwork of local militias and is awash in heavy weapons looted from Kadhafi's arsenals. The two years since Kadhafi was overthrown and killed by rebels Benghazi has seen scores of attacks targeting security forces and foreign missions, as well as more generalized violence. Earlier this week, a suicide car bombing killed at least 13 people in Bersis, about 30 miles from Benghazi. There was also a fatal attack on an American schoolteacher this month in Benghazi. And in October, Prime Minister Ali Zidan was abducted by gunmen in Tripoli and then freed hours later.

In November, Secretary of State John Kerry and his British counterpart William Hague met in London with Libyan Prime Minister Ali Zeidan and agreed to help Libya crack down on militia violence.

The Pentagon also said that the US military was prepared to train between 5,000 and 8,000 Libyan army troops at a base in Bulgaria. There were also plans to train a separate counter-terrorism unit, said Admiral William McRaven, commander of US Special Operations Command.

But Libya and the United States have also had disagreements: in early October, US commandos seized senior alleged Al-Qaeda figure Abu Anas al-Libi -- indicted for the twin 1998 bombings of US embassies in east Africa -- on the streets of Tripoli and whisked him away to custody aboard a warship.

The suspect was then moved to New York, where he pleaded not guilty to the charges.

Libi's capture embarrassed the Libyan government, which denounced it as "kidnapping" and claimed it had not been given advance notice of the seizure.