* Security situation in Tripoli still difficult
* Hardliners keeping up resistance to unity government
* Army advance in Benghazi could complicate deal
By Aidan Lewis and Ahmed Elumami
TRIPOLI, March 9 (Reuters) - Five years after the uprising that overthrew Muammar Gaddafi, Tripoli is on edge, somewhere between peace and war.
There is a semblance of normal life in the Libyan capital and glimpses of the unexpected - kite surfers zip across choppy waves and a group of amateur cyclists in matching kit pedal along a seafront highway.
Yet the armed groups that control the city are an unsettling presence. Gunmen in balaclavas staff checkpoints on key roads, and armed brigades have been flexing their muscles in late-night parades.
It is here that a unity government nominated abroad under a U.N.-backed plan is hoping to set up shop.
But two months after the deal was signed with limited Libyan support, Reuters interviews with residents and officials, and a string of recent incidents, show that resistance from hardliners in both Tripoli and the east is still getting traction, shrinking the space for the plan to succeed.
The hardliners in Tripoli present themselves as the true guardians of the uprising, protecting Libya against a counter-revolution and foreign meddling. Those in the east claim to be saving the country from Islamist extremism.
Both speak for some of the armed factions that hold real power in Libya, and are scared of losing influence, protection and access to the country's rapidly dwindling financial resources in a political transition.
In Tripoli's Martyrs' Square, where families stroll past dozens of men saying prayers at sunset, some support the unity government, saying they are fed up with violence, cash shortages and rising prices.
"We've had enough," said Fardous Boukhatwa, whose family was displaced by fighting in Benghazi and was visiting Tripoli with three of her children. "There is only one solution - reconciliation and forgiveness."
But others echo the criticism of the Tripoli hardliners. "The United Nations did not play the role of mediator, it was biased towards the east," said Abdulkarim Sadiq, a retired teacher from the suburb of Janzour. "They cannot bring peace to Libya - they just add fuel to the fire."
A group of teenage boys mention photos they saw on Facebook of Prime Minister-designate Fayez Seraj meeting the commander of Libya's eastern military forces, Khalifa Haftar, a former Gaddafi ally deeply mistrusted in the west.
For nearly two years, Tripoli has been under the control of armed factions that formed an alliance known as Libya Dawn to seize control of the capital.
They reinstated the old parliament, the General National Congress (GNC), and the newly elected chamber moved east to Tobruk.
The Dawn alliance has now splintered. Key brigades have said they will provide security for the unity government, but the situation is volatile.
Under the U.N.-backed plan, the GNC is meant to form a consultative chamber, and a few dozen moderates have been holding meetings in preparation.
After their third session was disrupted by protesters last week, one of those attending, Bilqasem Eggzait, said they might have to consider meeting in a different city.
The same day, a group that regularly protests against the unity government in Martyrs' Square appeared on a popular TV station to proclaim the unity government "illegal" and warn of "bloodshed and a fire of sedition" in the capital.
Early on Friday, the man nominated to head the State Council said rocket-propelled grenades were fired at his Tripoli office. The U.N. envoy to Libya swiftly condemned the incident, though the property later appeared undamaged.
On Sunday, three members of the committee tasked with preparing security in Tripoli for the new government were briefly detained, drawing further U.N. condemnation.
The chances of major clashes if the unity government came to Tripoli were small because a majority of Libyans support it, said Eggzait.
But with a unified security force to build and oil revenues at a fraction of their former value, the government would need to cut salaries for brigades of former rebels who added tens of thousands of men to the state payroll after the revolution, and this would be difficult. "Politics in Tripoli is not about ideology, it's about money," he said.
While recent violence in Tripoli has been limited to occasional gunfights and isolated clashes, Benghazi, Libya's second city, has been a battleground for Haftar's forces and a collection of armed groups including Islamic State.
After previous promises to "liberate" the city came to nothing, over the past two weeks the military has taken control of several key areas, allowing some residents to return to their homes and start repairing war-torn streets.
In the recently secured neighbourhood of Laithi, 42-year-old father of four Khairy Mohamed al-Qatrani said he had been able to return to his house "thanks to Khalifa Haftar, whose Karama (Dignity) operation has thwarted the plans of Islamic State to take control of Benghazi".
Qatrani said he hoped the army would be a neutral force in the future, but the military deadlock was broken as Haftar's allies in the eastern parliament, the House of Representatives (HOR), continued to block approval of the unity government, which includes Mahdi al-Bargathi, a Haftar rival, as defence minister.
The recent military push "very much has to do with Haftar's need to reassert himself as the saviour of the east in the face of challenges within his own camp," said Issandr El Amrani, North Africa director for International Crisis Group.
A majority of HOR members signed a declaration of support for the new government, but complained that hardliners had resorted to threats and physical force to prevent a vote.
A "crisis of trust" in the Tobruk chamber meant that voting to approve the government there had become impossible, lawmaker Ayman al-Nasr told Reuters.
Western diplomats, who say they can only provide sustained support for the fight against Islamic State in Libya at the request of a unity government, have looked on with growing exasperation.
The extremist group is in control of Gaddafi's home town of Sirte and has expanded to several other cities. This year it has launched a series of attacks on facilities in Libya's coastal "oil crescent".
Diplomats may now have to accept a return to negotiations, which could be complicated by the military advances in Benghazi and Haftar's enduring popularity.
Critics of the unity government plan say it was pushed through prematurely, before Libya's powerful armed factions were brought on board.
Unless this happens, with help from the regional powers that have backed both sides - Egypt and the United Arab Emirates in the east, Turkey and Qatar in the west - Libya's conflict will not be resolved, said Amrani.
"The political guys who stand in as proxies cannot negotiate for them at the end of the day," he said.
Additional reporting by Ayman al-Warfalli in Benghazi; editing by Giles Elgood