On 17 July 1517 the Sharif of Mecca gave away Ta'if to the Ottoman Sultan Selim I. As a sign of this, he surrendered to him the keys of the Islamic cities of Mecca and Medina. As part of the Hejaz, Ta'if was also given over to Ottoman control.