Libyan militias are out of control and holding thousands of people in secret detention centres, while the weak interim government struggles to assert its authority, the UN has heard.
The Security Council was told recent violence in Tripoli, Bani Walid and Benghazi highlighted the problem.
More than 8,000 pro-Gaddafi supporters are being held by militia groups, amid reports of torture, officials warned.
Four died in clashes in Bani Walid, a former Gaddafi stronghold, on Monday.
The UN's Libya envoy, Ian Martin, told the Security Council in New York on Wednesday that those clashes between armed residents of Bani Walid and revolutionaries had been misreported as pro-Gaddafi forces retaking the city.
Nevertheless, he said, it highlighted the challenge of reconciling the former leader's supporters and the rebels that had defeated them.
Militias were responsible for fatal clashes in Tripoli and fighting in other towns this month, he said.
"The former regime may have been toppled, but the harsh reality is that the Libyan people continue to have to live with its deep-rooted legacy," said Mr Martin.
He described that legacy as "weak, at times absent, state institutions, coupled with the long absence of political parties and civil society organisations, which render the country's transition more difficult".
Mr Martin said some steps had been taken towards demobilising ex-combatants.
But the government was struggling to establish its legitimacy, he added, with weapons freely available and various armed brigades having unclear lines of command and control.
While authorities had so far successfully contained any outbreaks of violence, they could escalate and widen in scope, he warned.
UN human rights chief Navi Pillay meanwhile raised concerns about detainees being held by revolutionary forces, saying there were some 8,500 prisoners in about 60 centres.
"The majority of detainees are accused of being Gaddafi loyalists and include a large number of sub-saharan, African nationals," she said.
"The lack of oversight by the central authority creates an environment conducive to torture and ill treatment.
"My staff have received alarming reports that this is happening in places of detention they have visited."
She urged the authorities to take control of these informal jails, review the cases, and deal with the prisoners in a legal framework.
Libyan Defence Minister Osama al-Juwali, who has been negotiating with militiamen in Bani Walid, told reporters on Wednesday that the situation was stable.
As he arrived, National Transitional Council (NTC) forces - loyal to the new government - gathered outside the town.
They were heavily armed and apparently poised to attack if talks failed, although one commander insisted they were there for "reconciliation".
Fighters in the town have reportedly expelled NTC forces into the surrounding desert.
Residents have told the BBC that 90% of the town was under militia control.