UN Secretary General Ban Ki-moon has warned that the future of Libya, and the stability of the whole Sahel region, is at stake as it faces the "terrifying threat" of Islamic State.
But he warned international powers not to "stoke the fires of conflict" in the country.
Ban left Mauritania on Saturday and headed to Algeria as part of a tour of West and North Africa.
While meeting Mauritanian leaders, including President Mohamed Ould Abdel Aziz and Prime Minister Yahya Ould Hademine, in the capital Nouakchott on Friday he said he was "deeply concerned about the situation in Libya".
Chaos has engulfed Libya since the 2011 NATO-backed ouster of dictator Muammar Gaddafi and rival administrations are being urged to sign up to a UN-brokered national unity government to help restore stability.
The internationally recognised government is based in the far east of the North African country.
The Islamic State group and other extremist organisations have exploited the power vacuum, making gains along the oil-rich coastal regions and triggering concern among Western nations over Islamist militants controlling territory just 300 kilometres (185 miles) from Europe.
"There are alarming reports of widespread human rights violations, including serious abuses that may amount to war crimes," Ban said in his comments Friday.
"All those with influence must use it to calm the situation and stop the fighting. It is utterly irresponsible for any outside player to stoke the fires," he added.
Ban said that his special representative Martin Kobler "is facilitating talks on a national unity government" as "we face the terrifying scourge of Daesh (IS) expanding in Libya and beyond its borders."
Delays would only worsen the dire humanitarian needs, he warned, adding that "Libya's future is at stake" and "the reverberations echo far".
Success in stabilising Libya would also benefit the whole Sahel region and "our world" in general, he added.
The UN chief also called for Mauritania's help in a territorial dispute between Morocco and a Western Sahara separatist group that has displaced tens of thousands in decades of fighting.
"Making progress on the situation in Western Sahara is also of importance here too," he said, referring to Mauritania. "Numerous refugees share the same culture and family ties with Mauritanians."
The United Nations has been trying to oversee an independence referendum for Western Sahara since 1992 after a ceasefire was reached to end a war that broke out when Morocco sent its forces to the former Spanish territory in 1975.
Before visiting Mauritania, Ban held talks in Burkina Faso. He will spend Saturday and Sunday in Algeria.