Libya’s rival administrations agreed on Sunday to hold elections within the next two years with a view to reunifying the country.