A ceasefire has been reached between armed factions fighting over the Libyan capital for more than a week, the United Nations said on Tuesday.