The United Nations refugee agency has said that a spike in violence between rival militias has displaced about 287,000 Libyans from their homes. Meanwhile UN chief Ban Ki-moon arrived in Tripoli Saturday for talks with the warring factions.

A spokesman for the UNHCR Adrian Edwards told reporters on Friday that an estimated 287,000 people have fled the conflict in Libya since it started three years ago in a NATO-backed uprising to topple its long serving leader Muammar Gaddafi.

Edwards said that in the last three weeks alone 100,000 people had been displaced from Warshefana, a suburb on the edge of Tripoli and a further 15,000 had fled the eastern city of Benghazi.

He said that aid agencies were stretched to the limit.

“The need for healthcare, food, and other basic commodities – plus for shelter ahead of winter – has become critical,” he said.

Adding that there are “major constraints in funding for the internally displaced, while the security situation over recent months has posed challenges in reaching those in need.”

In many cases Libyans have opened their homes to refugees. In the small town of Ajaylat 80 kilometers west of Tripoli the community of 100,000 had taken in 16,000, while those unable to find a home were sleeping in schools, parks and buildings that have been turned into emergency shelters.

“As well as the impact on the local population, the fighting is also affecting refugees, asylum-seekers, and migrants in Libya – many of them from Middle Eastern countries and Sub-Saharan Africa,” he said.

More than 165,000 people have arrived on southern Europe’s shores so-far this year, the majority of them are from Libya and half of those had travelled first from Syria or the brutal regime in Eritrea.

Meanwhile UN Secretary-General Ban Ki-moon is scheduled to meet with the deputy speaker and other lawmakers from Libya’s internationally recognized House of Representatives. He arrived in Tripoli on Saturday accompanied by EU foreign policy chief Federica Mogherini.

The Libyan government was forced to flee to Tobruk in August after armed militias from the town of Misrata seized control of the capital.

The UN has urged the different factions to end militia fighting and two weeks ago started a dialogue between them to try and aid the process. Ban Ki-moon will also meet members of Libya’s assembly from Misrata, who have boycotted its sessions. As these members have links to the rival unofficial parliament in Tripoli diplomats hope a breakthrough can be made.

“But 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. This is what hangs in the balance today for the future of Libya,” Ban said upon his arrival on Saturday.

Well-armed militias, who helped topple Gaddafi in 2011 and claim legitimacy for running the country, have pushed aside Libya’s weak central government and impotent national army.

Ban added that without a representative fully government Libya would not have a future.

“In the first place, the purpose of this dialogue will be to put an end to the institutional crisis. The country cannot afford to be politically divided for such a long time. Libya needs one parliament that represents all Libyans,” he said.