"All four US military personnel being held in Libyan government custody have been released," State Department spokesperson Jen Psaki said adding that the US is still trying to ascertain the facts of the incident.
The four were released just two hours after the State Department announced their detention, an official said.
"These four military personnel were operating in an area near Sabratha as part of security preparedness efforts when they were taken into custody," Psaki said.
"We value our relationship with the new Libya. We have a strategic partnership based on shared interests and our strong support for Libya's historic democratic transition," Psaki said.
More From This Section
Americans in Libya have been targeted more than once since 2011, when the regime of dictator Muammar Gaddafi was overthrown by local rebels 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.
And earlier this month an American teacher was gunned down during his morning jog in Benghazi in an attack blamed on Islamist extremists.