By Aidan Lewis and Ulf Laessing
TRIPOLI (Reuters) - For the United Nations, it was a chance to clip the wings of powerful armed groups who had held the levers of power in the Libyan capital for years.
The militia were on the back foot after suffering losses to rival factions in the latest convulsion of violence to shake Tripoli; the U.N. brokered a ceasefire in September, then encouraged the government to start replacing the militia with regular police.
Before they got far, Haithem Tajouri, a powerful militia leader who had left the country two months before, returned with a flourish.
The head of the Tripoli Revolutionaries Brigade (TRB) toured the city centre with his entourage, stopping their vehicles outside banks which unexpectedly extended their opening hours, allowing cash-starved residents to withdraw money.
"Do you want cash?" Tajouri shouted to women queuing at one bank, an eyewitness said, declining to be named for security reasons.
Tripoli residents posted messages on social media saying Tajouri had arranged the extra access, causing more people to flock to the banks.
Last month, TRB forces patrolling central Tripoli showed Reuters the spot behind the central bank where they said they had driven black market money traders away several times over recent weeks, another crowd-pleasing move.
Tajouri may have acted partly to shore up his own position after his absence and the subsequent killings of commanders affiliated with him sparked speculation his forces were fragmenting.
But his actions also demonstrated the power accumulated by men whose armed followers dominate the city of three million, blocking efforts to end Libya's post-revolution turmoil.
Curbing the militias is crucial to plans, guided by the United Nations, to stabilise the oil-rich North African state nearly eight years after an uprising against Muammar Gaddafi, backed by NATO, splintered the country.
Their presence has also complicated plans for elections, initially planned for Dec. 10 and now postponed to next year.
Fighting broke out in August when some militias based outside Tripoli attacked the TRB and three other large groups with strongholds in the capital, angered by their dominance over public money and state contracts.
Since September a ceasefire has been largely observed, with the United Nations and the weak Government of National Accord (GNA) trying to secure a lasting truce.
As part of this, authorities say militias have begun a gradual retreat from strategic sites in Tripoli including banks and ministries. A new interior minister, Fathi Bashagha, has made high-level changes.
The militias are supposed eventually to be integrated into security forces or demobilised, as police take control of two inner rings in Tripoli and military units secure the outskirts, according to three people briefed on the arrangements.
Western countries had previously tried building up an army and police, but largely gave up when the country split between rival governments in 2014.
Under a U.N. deal that bought a new government to Tripoli in 2016, a handful of armed groups entrenched their power, hampering efforts to reunite rival governments and factions in Tripoli and the east.
Some analysts and diplomats say the current U.N.-backed security plan has more chance of succeeding than in the past, arguing that militia leaders are seeking to protect their earnings from a new threat, sanctions.
This year the U.N. Security Council and the U.S. Treasury have issued asset freezes and travel bans against six alleged migrant smugglers, a former oil port blockader and, last month, Salah Badi, a militia leader from the military and business stronghold of Misrata.
But the depth of militia influence meant it was unclear if the GNA had the will to enact change, or could find recruits for a professional force and employment for those who demobilise, a Western diplomat said.
"A lot of militia leaders are suing for peace because they want to keep their ill-gotten gains," he said. "The problem is that there are no jobs (for their followers)."
Some residents see the new arrangements as largely cosmetic, with guards changing uniforms while staying loyal to militia commanders.
U.N. Libya envoy Ghassan Salame told Reuters in a statement that "key appointments have been made and brave decisions have been taken" since the ceasefire.
But, he added, "like most Libyans, we feel frustrated with the GNA for their very slow implementation of the arrangements".
For now, key armed group leaders remain in the foreground.
Tajouri, known for his fashion sense and white G Class Mercedes, was widely seen as more powerful than the prime minister before his absence during recent fighting raised questions over his standing.
His return from the Gulf in a private jet, dressed in blue Emirati robes, triggered speculation that he was aligning himself with the United Arab Emirates, one of the major external players in Libya's conflict.
A report by a U.N. panel of experts last year documented what it said was UAE support for Khalifa Haftar, a veteran commander who controls eastern Libya and has long pledged to "liberate" Tripoli by forging alliances in the west. The panel said its requests for information from the UAE had received no response.
Reuters asked the UAE's foreign ministry and media council whether the country supported Haftar and Tajouri and saw an alliance between them as a way to stabilise Libya: officials were not immediately available for comment.
Rada, another major group with a base at Tripoli's only functioning airport, is led by Salafist Abdulraouf Kara, who has links to a network of brigades beyond the capital aligned with the ultraconservative religious ideology.
Tajouri and Kara, neither of whom agreed to an interview, hold high-value prisoners including ex-Gaddafi figures. Their fortunes have roused the envy of groups outside Tripoli.
Some come from Misrata, home to a mix of moderates and radical groups; the latter have been trying to regain lost influence in Tripoli.
Badi, under U.S. and U.N. sanctions for his Al Somoud brigade's attacks on Tripoli, said the international community had helped install militias that mixed the "tyranny" of the Gaddafi era with Salafist ideology from Saudi Arabia.
Kara and other "quietist" Salafists, including some who have fought for Haftar, tend to respect the authority in power. By contrast, Badi and other Islamist-leaning figures cast themselves as militant defenders of the revolution.
"Their (armed group) leaders protected the government and now control it. They rob the government," Badi told Reuters.
Misrata moderates view Badi as a marginalised figure discredited by the assaults on Tripoli. But experts say officials need to engage with a wide range of actors.
"If there is not sufficient outreach to armed groups outside Tripoli to get their buy-in, the new security arrangements risk exacerbating existing tensions," said Juan Garrigues of DAG, an independent group that works on dialogue in western Libya.
With elections pushed back, the international community is pinning its hopes on a national conference planned by the U.N. for early 2019 that would hash out the basis of a settlement.
Until then "the danger is that you're merely shifting the deckchairs on the Titanic", as the underlying situation for most Libyans continues to deteriorate, said the diplomatic source.
Despite plans for an audit of central bank spending, there was still a "total lack of transparency" in the way rising oil revenues are spent, he said.
Militias have penetrated financial institutions, analysts say.
Libya's sovereign wealth fund was forced to recruit staff from Nawasi, one of the main Tripoli groups, and a TRB faction tried to gain influence over the state oil firm NOC, according to a report by the U.N. panel of experts on Libya.
Deputy Prime Minister Ahmed Maiteeg told Reuters this trend would be reversed as a currency devaluation and increased access to foreign currency deprive militias of key sources of revenue – extortion rackets at banks they control and privileged access to dollars resold at huge profits on the black market.
There was more communication with the armed groups, he said.
"We see some improvement, but not as much as expected ... that's why from time to time we see some pressure on Tripoli -- that militia will not hand over very easily."
(Writing by Aidan Lewis; editing by Philippa Fletcher)