from the 10th century to the early 20th century, mecca and medina were under the control of a local arab ruler known as the sharif of mecca, but at most times the sharif owed allegiance to the ruler of one of the major islamic empires based in baghdad, cairo or istanbul. most of the remainder of what became saudi arabia reverted to traditional tribal rule.