Clashes rocked Libya's capital early on Tuesday as the parliament-appointed prime minister, Fathi Bashagha, tried to take over government there but was forced back out by a rival administration that refuses to cede power.
Bashagha entered Tripoli overnight after two months of stalemate between Libya's rival administrations, but withdrew hours later as fighting broke out, his office said.
The crisis risks plunging Libya back into prolonged fighting after two years of comparative peace, or returning it to partition between the eastern-backed government of Bashagha and a Tripoli administration under Abdulhamid al-Dbeibah.
Political deadlock has already led to a partial blockade of Libya's oil facilities, cutting its main source of foreign revenue by half. Diplomacy to resolve the crisis or lay the ground for new elections is making slow progress.
The sound of heavy weapons and automatic gunfire reverberated across Tripoli on Tuesday morning. Schools were cancelled and the normally heavy rush hour traffic was sparse, but the clashes stopped after Bashagha's withdrawal.
"I don't think things will just return to being cool and static and relaxed," said Libya expert Jalel Harchaoui, adding that Dbeibah would likely try to put more pressure on the factions in Tripoli allied to Bashagha.
However, wider conflict seemed unlikely, he said, given Bashagha's rapid withdrawal from Tripoli.
Later on Tuesday, Dbeibah toured the areas where the clashes had taken place, speaking to passers by. In a statement, his government called Bashagha's convoy "an outlawed armed group trying to sneak into the capital under darkness".
Bashagha on Twitter accused Dbeibah's allied forces of a "dangerous military escalation" and said their actions showed Dbeibah's government would be unable to hold any credible election.
With neither side apparently able to establish a decisive military advantage across the country, Libya seems set for a longer period of deadlock, with Dbeibah firmly entrenched in Tripoli and his foes unable to take it.
That may prolong the shutdown of major oil facilities by forces in eastern Libya.
Libya has had little security since the 2011 NATO-backed uprising that ousted Moammar al-Gaddafi and its split in 2014 between rival eastern and western factions before a 2020 truce that brought it under Dbeibah's fragile unity government.
A plan for an election in December collapsed amid arguments among major factions and prominent candidates over the rules. In addition the parliament, which had sided with the east during the war, moved to appoint a new administration.
The unity government's prime minister Dbeibah rejected the parliament's moves, saying his administration was still valid and he would only hand over power after an election.
Bashagha, a former interior minister who like Dbeibah comes from the powerful coastal city of Misrata, has repeatedly said he would enter Tripoli without violence. His previous attempts to do so ended with his convoy blocked by rival factions.
Last week, the parliament said Bashagha's government could work for now from Sirte, a central city near the frozen front line between eastern and western factions.
Diplomacy has focused on talks between the parliament and a Tripoli-based legislative body to lay the ground for another attempt to settle Libya's conflict by holding an election.