Top US and European leaders have called for a ceasefire in Libya and for the United Nations to take on a major role in helping to stop the spiralling violence.

The appeal came after a conference call between US President Barack Obama, German Chancellor Angela Merkel, French President Francois Hollande and the Prime Ministers of Britain and Italy, David Cameron and Matteo Renzi.

"The five heads of state and government condemned the violence against civilians, the intimidation of state representatives and the disruption of the political process," a German government statement said.

They called on the United Nations "to play an essential role in facilitating the political process" in order to restore stability in Libya.

The leaders agreed "an immediate ceasefire between the militias in Tripoli was necessary," it added.

The clashes in Tripol are the most violent since a 2011 armed revolt that overthrew longtime dictator Muammar Gaddafi.

The violence started with an assault on the airport on 13 July by armed groups, mainly Islamists.

The fighting spread to other cities today and a huge fire erupted at an oil depot outside the Libyan capital, threatening its vital oil industry.

The violence has led the United Nations and the United States to withdraw their personnel from Libya while other Western powers have told their nationals to leave the country.