(Reuters) - Libya's worst fighting for two years suddenly hit the capital, Tripoli, on Saturday. This explains what led to the violence, why it matters, and how things may play out.
HOW DID LIBYA FALL APART?
Libya's fault lines surfaced as local groups took different positions in the 2011 NATO-backed uprising that toppled Muammar Gaddafi.
An attempted democratic transition slid out of control as armed groups built local power bases and coalesced round rival political factions, seizing control of economic assets.
After a battle for Tripoli in 2014, one faction including most parliament members moved east and recognised Khalifa Haftar as military chief, eventually setting up a parallel government.
A U.N.-backed agreement led to a new internationally recognised government in Tripoli, but eastern factions spurned the deal and Haftar's Libyan National Army (LNA) attacked the capital in 2019.
The squabbling armed factions that controlled western Libya came together to back the Tripoli government against Haftar and they repelled his assault in 2020 with help from Turkey, leading to a ceasefire and a new U.N.-backed peace process.
HOW DID THE LATEST DISPUTE UNFOLD?
The peace process brought in a new Government of National Unity under Prime Minister Abdulhamid al-Dbeibah with a mandate to oversee national elections scheduled for December 2021, but there was no agreement on rules for the vote and the process collapsed.
In eastern Libya, the parliament declared Dbeibah's government illegal and appointed a new one under Fathi Bashagha. Dbeibah rejected its moves, saying he would cede power only after an election.
Meanwhile the western Libya factions that had joined together against Haftar were again jostling for position in Tripoli with occasional skirmishes, and some saw Bashagha as their best bet for advancement.
Bashagha tried to enter Tripoli soon after he was appointed in March, but pro-Dbeibah factions blocked his convoy. He tried again in May, but left Tripoli after a brief shootout.
As the months passed, alliances and coalitions among the Tripoli factions shifted as both Dbeibah and Bashagha tried to court key players. On the streets of Tripoli, armed forces rubbed up against each other's territory.
When fighting erupted between two groups on Friday night, factions aligned with Bashagha began mounting what looked like coordinated attacks in a new effort to install him in the capital. But the move failed, apparently leaving Dbeibah more firmly entrenched.
WHAT ARE THE CHANCES OF A POLITICAL DEAL?
The powerful eastern faction of Haftar and parliament speaker Aguila Saleh has shown little willingness to compromise on its goal of removing Dbeibah and installing Bashagha.
However, with Bashagha seeming unable to build a coalition of western factions that can install him in Tripoli, they may have to think again.
Turkey's continued military presence around Tripoli, where it maintained air bases with drones after helping fend off the eastern assault in 2020, means another Haftar offensive against the capital looks very unlikely for now.
Some politicians have raised the idea of another attempt to form a new government that all sides can accept - something Dbeibah would likely try to block.
Meanwhile, diplomacy has stalled and agreement on how to hold elections as a lasting solution to Libya's political disputes looks further away than ever.
International efforts to broker agreement have been hampered by disagreement among the countries involved and among local factions that many Libyans believe want to avoid elections in order to hang onto power.
Many among Libya's population of nearly 7 million fear that means that however the next period of negotiations and positioning play out, it will only be followed by another outbreak of violence.
HOW DOES IT ALL AFFECT LIBYA'S OIL?
Control over revenues from Libya's main export, its oil output of up to 1.3 million barrels per day, has long been the biggest prize for all the main political and military factions.
Groups have repeatedly shut down output before as a tactic to put pressure on the government in Tripoli where all foreign oil sales revenue is channelled into the central bank through international agreements.
Forces aligned with Haftar, whose sway extends across much of the territory that includes main oil fields and export terminals, have been responsible for the biggest shutdowns in recent years.
The last shutdown, which reduced exports by about half, ended when Dbeibah replaced the National Oil Corporation head with an ally of Haftar - a move some saw as an effort to court the eastern commander and make him more open to a political deal.
That may be enough to stop another shutdown while pro-Bashagha factions work out their next move. But with Libya's political tangle so far from resolution, there seems little likelihood that oil exports will stay untouched for very long.
(Reporting by Angus McDowall; Editing by Frances Kerry)