UN chief Ban Ki-Moon on a surprise visit to Libya Saturday urged warring factions to end the turmoil gripping the North African nation since Moamer Kadhafi was toppled in 2011.
The authorities have struggled to impose their will across a country awash with weapons and powerful militias that ousted and killed the veteran dictator.
"Let me be clear: if violent confrontations do not cease immediately, if sustainable peace is not restored, prosperity and a better life will be a distant dream," Ban told rival parliamentarians, according to an official transcript of his remarks.
He flew to Tripoli just weeks after the outgoing government admitted from its safe refuge at Tobruk in the east that it had in effect lost control of the capital to armed militias.
The UN chief spoke ahead of meetings with political parties to shore up talks aimed at ending a split that has further destabilised the oil-rich nation.
The discussions would include the deputy president of the house of representatives, other members of the house and lawmakers who boycotted parliamentary sessions, it said.
Ban urged the formation of a national unity cabinet, stressing the importance of "a strong government able to implement decisions" in the country where militias control swathes of territory.
"There is no alternative to dialogue," Ban said ahead of the meeting of rival MPs, also attended by the incoming EU foreign policy chief, Italian Foreign Minister Federica Mogherini, as well as envoys from Britain, France and Malta.
The UN mission chief in Libya, Bernardino Leon, managed to bring the rival factions together for talks in the remote oasis town of Ghadames on September 29.
Ban on Saturday called the talks "a first courageous step", adding "I am here to support the process that was initiated in Ghadames."
Libya's parliament, elected in June, is recognised by the international community but contested by the militia controlling most of Tripoli and by Islamists who hold much of the eastern city of Benghazi.
- 'No alternative to dialogue' -
Signup to our newsletter and follow us on Facebook and Twitter!
The majority faction in the legislature has been meeting in the far eastern town of Tobruk near the border with Egypt.
"There is no alternative to dialogue," Ban said on Saturday.
"It is my conviction that all problems in Libya can be solved through dialogue. Nevertheless, we understand that the path will be long and difficult."
The UN refugee agency said on Friday that clashes between rival militias had driven an estimated 287,000 people from their homes, including about 100,000 who have fled the outskirts of the capital.
Another 15,000 people were estimated to have been displaced around Benghazi, the country's second city, it said.
"The need for healthcare, food, and other basic commodities -- plus for shelter ahead of winter -- has become critical," said UN refugee agency spokesman Adrian Edwards.
Last week, the UN Security Council warned of possible sanctions against those who reject peace in Libya.
Since the beginning of September, Islamists have been trying to capture Benghazi airport, with its military and civilian airfields.
At least 17 people have been killed this week in fighting for the airport, the last remaining bastion of forces loyal to a prominent former general, Khalifa Haftar, who launched a military campaign against Islamists in May.
On Friday, a colonel was killed in Benghazi, taking the army's death toll there to 130 in two months, a military official told AFP on Saturday.
Ban on Saturday called on "all groups to stop fighting", but referred specifically to Haftar's and the Islamist Ansar al-Sharia militia group that he has been battling in Benghazi.
Benghazi was the cradle of the uprising against Kadhafi, and is regularly the scene not only of fighting but also the murders of members of the security forces, political activists and journalists.