TRIPOLI (Reuters) - A huge fuel depot in Libya’s capital burned out of control on Monday, set ablaze in fighting between rival militias that has driven the country to chaos three years after the NATO-backed revolt that toppled Muammar Gaddafi.

Combat over control of the nearby airport forced firefighters to withdraw, abandoning their attempts to extinguish the blaze ignited by a missile strike that hit millions of litres of fuel.

Foreign governments have looked on powerless as anarchy sweeps across the North African oil producer. Western countries have urged their nationals to leave, shut their embassies and pulled diplomats out, after two weeks of clashes among rival factions of former rebels killed nearly 160 people in Tripoli and the eastern city of Benghazi.

The Netherlands, the Philippines and Austria on Monday prepared to evacuate diplomatic staff. The United States, United Nations and Turkish embassies have already shut operations after the worst violence since the 2011 uprising.

Two rival brigades of former rebels fighting for control of Tripoli International Airport have pounded each other’s positions with Grad rockets, artillery fire and cannons for two weeks, turning the south of the capital into a battlefield.

“It is out of control. The second tank has been hit and the firefighters have withdrawn from the site as the fighting has resumed in the area,” said Mohamed Al-Harrai, a spokesman for the national oil company said of the blaze, which choked the sky above the city with black smoke.

In the three messy years since the fall of Gaddafi, Libya’s fragile government and fledging army have been unable to control heavily armed former anti-Gaddafi fighters, who refuse to hand over weapons and continue to rule the streets.

Libya has appealed for international help to stop the country from becoming a failed state. Western partners fear chaos spilling across borders with arms smugglers and militants already profiting from the turmoil.

After the U.S. evacuation, U.S. Secretary of State John Kerry said the “free-wheeling militia violence” had been a real risk for American diplomats on the ground, and called for an end to the violence. U.S. ambassador Chris Stevens was killed by militants along with three others in Benghazi in September 2012. In neighbouring Egypt, President Abdel Fattah al-Sisi has repeatedly warned about militants capitalising on Libya’s chaos to set up bases along their mutual frontier.

PALL OF SMOKE OVER TRIPOLI

Libya’s government has asked for international help to try to contain the disaster at the fuel depot on the airport road, close to other tanks holding gas and diesel.

The conflict has forced Tripoli International Airport to shut down. Airliners were reduced to smouldering hulks on the tarmac and the aviation control centre was knocked out.

“This crisis is causing lots of confusion, lots of foreigners are leaving and diplomats are also departing through here,” said Salah Qahdrah, security controller at Mitiga air base, now a secondary airport operating limited flights.

Monday was the start of Eid el-Fitr festivities to mark the end of the Muslim holy month of Ramadan, and fighting had eased in the morning. But fuel supplies were growing scarce in the capital with power cuts increasingly frequent.

The health ministry said on Sunday nearly 160 people had been killed in fighting in Tripoli and in Benghazi where regular forces and militias have clashed in open street battles with Islamist militants entrenched there.

WARPLANES, ATTEMPTED HIJACKING

With Libyan security deteriorating, the United States evacuated its embassy in Tripoli on Saturday, spiriting diplomats across the border into Tunisia under heavy military guard including warplanes and a Marine escort.

Slideshow ( 5 images )

A British embassy convoy leaving by road for Tunisia came under gunfire in an apparent attempted hijacking on Sunday outside Tripoli as it headed to the border. There were no injuries, but one of its armoured vehicles was damaged.

The Italian embassy has helped 100 citizens and other nationals leave by road or by military aircraft, foreign ministry officials said, while the Dutch embassy was preparing to temporarily close with the departure of its last citizens.

Austria and the Philippines were also down to basic staffing on Monday, with Manila urging its nationals to evacuate “before all routes and options become extremely difficult.”

Libya’s government and special envoys from the United States, the United Nations and European countries on Saturday pushed for a cease-fire and a political deal within the newly elected parliament due to begin sessions in August.

Slideshow ( 5 images )

“We have been working to try and improve the situation in Libya through the work of our special envoy alongside the U.S. special envoy, to try and get more of a dialogue going,” British Prime Minister David Cameron’s spokeswoman said.

Since Gaddafi’s demise, Libya has struggled to keep its transition to democracy on track, with its parliament deadlocked by infighting among factions and militias often using threats of force against political rivals.

FACTIONS, TRIBES AND OIL

Former fighters have repeatedly stormed parliament and taken over ministries. One former rebel commander working for the state mutinied and blockaded oil ports for nearly a year to demand more autonomy for his eastern region.

Libya’s oil production was at 500,000 barrels per day last week, down slightly from previous levels when output had begun to recover following the end of the port blockade. Oil ministry officials on Monday declined to give updates on output.

Production was more than three times as high before the civil war that toppled Gaddafi. The desert country depends almost entirely on oil exports to feed and employ its population of around 6 million people.

Thousands of ex-rebels have been put on the state payroll as semi-official security forces in an attempt to co-opt them, while others have joined the nascent armed forces.

But often their loyalties are stronger to region, tribe or faction. Fighting now involves two loose confederations of armed factions and their political allies in Tripoli and Benghazi, whose deepening standoff is shaping Libya’s transition.

In Tripoli, on one side are troops from the western town of Zintan and their allies the Qaaqaa and al-Sawaiq brigades, who include some former Gaddafi troops who rebelled in 2011. They have controlled the airport since the fall of the capital.

Against them are ranged various Islamist-leaning militias allied to the port city of Misrata, which is closer to the Muslim Brotherhood movement in Libya. Those militia have now dug in a few kilometres from the airport.

In Benghazi, regular special forces and air force units have joined up with a renegade former army general who has launched a self-declared war on Islamist militants in the city. More than 55 people have been killed over the last week there.