Mahmud of Ghazni (November 2, 971 - April 30, 1030), was the most prominent ruler of the Persian Ghaznavid dynasty of Turkic origin and ruled from 997 until his death in 1030. Mahmud turned the former provincial city of Ghazni (now in Afghanistan) into the wealthy capital of an extensive empire which extended from Afghanistan into most of Iran as well as Pakistan and regions of North-West India. He was also the first ruler to carry the title Sultan (authority). Sultan Mahmud's first campaign was against the Qarakhanid Empire, which controlled the ####northern portion of his Empire. After his defeat, he enlisted the alliance of the Seljuk Turks in southern Soghdia and Khwarazm who aided him in securing the north by diplomacy (998). In 999 'Abd al-Malik II of the Samanids engaged in hostilities with Mahmud over Khorasan after political alliances shifted under a new Samanid Emir. Mahmud's campaigns seem to have been motivated by both religious zeal against both the Fatimids Shiites and non-Muslims; Buddhists, Jains and Hindus. His principal drive remained the Ismaili Shiites, Buyid Iran as well as favor and recognition of independence from the Abbassid Caliphate. He transformed Ghazni, the first centre of Persian literature, into one of the leading cities of Central Asia, patronizing scholars, establishing colleges, laying out gardens, and building mosques, palaces, and caravansaries. He patronized Ferdowsi to write the Shahnameh; and, after his expedition across the Gangetic plains in 1017, of the scholar, Biruni to compose his “The history of Iran” in order to understand the Indians and their beliefs. The Ghaznavid Empire was ruled by his successors for 157 years.