Libyan authorities wrested back control of Tripoli International Airport from ex-rebels who seized the runway, surrounding planes and grounding all flights after their leader's apparent arrest, officials said.
It took until evening for the authorities to regain control of the airport when loyalist forces stormed it after negotiations with the militiamen broke down, deputy interior minister Omar Al Khadrawi told journalists.
Flights were not expected to resume for at least 24 hours because of the damage caused to the airport's infrastructure.
The assault by the militiamen on the Libyan capital's main gateway to the outside world underlined the massive task facing the authorities in reintegrating the disparate armed groups that took part in the overthrow of now slain dictator Moamer Kadhafi's regime last year.
The raid was carried out by gunmen who fired into the air and slightly wounded an airport employee, causing panic among travellers, according to the official LANA news agency.
"It is total confusion. Everyone is fleeing," an official at the airport told AFP, adding that several armoured vehicles were positioned on the tarmac blocking traffic.
"Cars mounted with anti-aircraft guns and armed men are surrounding the aircraft and preventing them from moving," another official said, adding that some passengers were forced to leave planes.
The motive of the gunmen was to pressure the government to explain the whereabouts of their leader, Abu Ajila al-Habshi, according to LANA.
Tripoli's security commission, which answers to the interior ministry, said it had nothing to do with "the disappearance and abduction of Colonel Abu Ajila al-Habshi" and that it was still tracking those responsible.
The attack forced the diversion to Tripoli's Matiga military air base of some flights, including to and from Amman, Istanbul, Rome and Vienna, according to officials and flight monitoring websites.
Trucks mounted with heavy weapons were parked under some airliners and gunmen shuttled in and out of the luggage hall which opens out onto the tarmac, an AFP correspondent reported.
"Members of the Al-Awfya brigade entered the plane. They were fully armed and they forced us off," Ahmed Loshta, a Tripoli resident who had been due to fly to Italy, told AFP.
Dozens of pickup trucks mounted with anti-aircraft guns arrived on the scene shortly before sunset. Their arrival was followed by intermittent salvos of gunfire, an AFP journalist at the scene reported.
Loyalist forces took action after negotiations broke down, the deputy interior minister said.
"The authorities have complete control over the airport," Khadrawi told reporters after the operation, adding that dozens of assailants were arrested and stripped of their weapons.
The ruling National Transitional Council had authorised the interior and defence ministries, who oversee a broad constellation of brigades made up of former rebels, to "use all means necessary, including force," to retake the airport.
"Some of the assailants fled and others turned themselves in without resistance," he said, adding between 30 and 40 people were arrested.
Khadrawi said the "saboteurs" also blew up a hangar and set fire to fields surrounding the airport.
"We will alert airline companies that the airport will be shut over the next 24 hours," he said, adding that technical issues, such as the rupture of communication lines, needed to be fixed before flights could resume.
The ruling NTC is still struggling to fully integrate many Libyans who fought forces loyal to Kadhafi before he was ousted and killed in October last year.
The former rebel fighters have remained in organised armed brigades. The ministries of defence and interior have integrated many of them into their ranks but some are still a law unto themselves.
The NTC took control of Tripoli airport in April from a Zintan brigade that had been guarding the facility since the capital's liberation in August 2011.
Such militias secured many strategic sites in Libya after they defeated Kadhafi loyalists backed by Nato led air strikes during last year's Arab Spring-inspired revolution.
The NTC has called for their handover, but several other similar militias of former rebels are still guarding important buildings and facilities in the North African country.
Monday's assault on Tripoli airport came as Libya prepares to hold elections for a 200-seat constituent assembly by June 19, as pledged by the NTC.
Flashes of violence, such as a deadly raid on government headquarters last month, have raised concerns over the capacity of authorities to secure the first election after decades under Gaddafi.
Armed clashes broke out late Monday between military police and a militia group in the eastern city of Benghazi after a youth was killed at a checkpoint, a security source said.
Fighting was continuing around midnight (2200 GMT) near the military police headquarters after a young militia member was shot dead at a police checkpoint to the west of the town.