For 1,000 years, this city on a hilltop has been a center of Islamic faith in the Horn of Africa, with a forbidding, 13-foot wall surrounding ancient mosques and serpentine alleyways.