Ban's visit is his second to Libya since the 2011 fall of longtime dictator Muammar Gaddafi. It comes after the UN launched a dialogue late last month to mediate between the warring Libyan groups.
Libya witnessed a spasm of violence this summer when militias mainly from the western city of Misrata and groups allied to Islamists swept through the capital, backing a government appointed by the country's previous parliament.
In a televised session attended by Ban, as well rival politicians and European diplomats, the UN Special Representative for Libya Bernardino Leon said the Libyan capital will be "for the next few hours again the capital of a united Libya."
The meeting was attended by the deputy head of the elected parliament and a representative of the parliamentarians who have boycotted the new House of Representatives.