A group of U.S. commandos who landed in Libya on Monday were ordered to leave almost immediately because of a possible mix-up between the Libyan air force and army, U.S. and Libyan officials said Thursday.

Senior U.S. defense officials, who spoke on condition of anonymity, confirmed the incident to NBC News after the Libyan Air Force posted pictures to its Facebook page appearing to show the group of U.S. Special Operations Forces at one of its air bases.

Libya has been in chaos since the overthrow of Moammar Gadhafi in 2011. The incident happened Monday but only came to light Thursday, just as Libya's rival parliaments signed a landmark United Nations-sponsored deal to form a government in the war-ravaged country, according to The Associated Press.

American commandos have been "in and out of Libya" for "some time now," according to the U.S. officials, but purely to advise Libyan forces rather than conduct combat operations or training.

An image from the Facebook page of the Libyan Air Force, showing what it said was the plane which carried U.S. military personnel to Libya on Monday. Libyan Air Force

One U.S. defense official suggested the group was asked to leave because of a lack of communication between the base in Wattiya, where they landed, and the Libyan forces who would normally "engage" with the American advisers.

This theory appeared to mesh with the Libyan Air Force's Facebook post, which said "a U.S. military plane landed with 20 U.S. soldiers aboard … without prior coordination."

It said the soldiers "disembarked in combat readiness wearing bullet proof jackets, advanced weaponry, silencers, handguns, night vision devices and GPS devices."

When questioned by Libyan soldiers, the Americans aid they were "in coordination with other members of the Libyan army," the Libyan Air Force said.

"The response from your heroic army stationed at Watiya base was to tell them to depart immediately and the group left , keeping their equipment with them," it added.

In a stark illustration of the fractured nature of Libyan society, the country's own air force said in its Facebook status that there were "so many questions about who is dealing with foreign armies under the cover of the [Libyan] army."