A ceasefire has been reached between armed factions fighting over the Libyan capital for more than a week, the United Nations said on Tuesday, but it was unclear how it would be implemented.