The United Nations is preparing to deploy up to 250 peacekeepers to Libya to guard its base in the capital as part of a plan to return its operations to the country, the head of the organisation’s mission there said on Friday.

Backed by Western governments, the UN is trying to heal a rift between Libya’s two rival governments, to tackle growing militant violence and people smuggling from its northern coast.

The mission has been based in Tunis since 2014 but has gradually increased its presence on the ground in Libya and has been planning for months for a fuller return.

The military unit would probably consist of around 150 people, Jean-Pierre Lacroix, UN Under-Secretary-General for Peacekeeping Operations, told a news briefing in Geneva.

Deploying the peacekeepers to the base in Tripoli “will mean that around the beginning of October we can carry out a significant part of our work in Libya,” said Salame, who has headed the mission since June.

The rival leaders have pledged to work towards elections in 2018 and a conditional ceasefire in a conflict which broke out after the 2011 ousting of strongman Muammar Gaddafi.

Salame said there were many issues to address to ensure a vote brought lasting change, including writing constitutional and electoral laws.

“We need to be sure everyone accepts the final result,” he said. “Let’s not forget that presidential elections would be the first ever.”

Meanwhile, UN human rights chief Zeid Ra'ad Al Hussein on Friday accused the European Union of "turning a blind eye" to the brutality faced by migrants held in Libya, and urged "serious action" to protect them.

"Some migrants die of thirst, hunger or easily-cured illnesses, some are tortured or beaten to death while working as slave labour, others are just casually murdered," Hussein said.

Hussein detailed these and other abuses -- including the rape of women "in some cases, every night" -- that hundreds of thousands of migrants are suffering at the hands of authorities in Libyan detention centres in the country.

He said their situation had been "appalling" during dictator Gaddafi's rule but had turned "diabolical" since his ouster.

Italy and the European Union have been financing, training and providing aid to Libya's coastguard to stop smugglers from taking migrants and refugees in flimsy boats across the Mediterranean to Europe.