Violence and religious and ethnic divisions underline security challenges the new president will face.