Mahmud of Ghazni the first ruler in history to assume the title of “sultan,” founded the Ghaznavid Empire.
His title signified that the Muslim Caliph remained the religious leader of the empire despite being the political leader of a vast swath of land, encompassing much of what is now Iran, Turkmenistan, Uzbekistan, Kyrgyzstan, Afghanistan, Pakistan, and northern India.
Mahmud is said to have made seventeen raids into India.On the frontier of India, there existed the Hindu Shahi kingdom which extended from the Punjab to Kabul.
The initial raids were against the Hindu Shahi kingdom in which its king Jayapala was defeated in 1001. His successor Anandapala fought against Mahmud but he was also defeated in the Battle of Waihind, the Hind Shahi capital near Peshawar in 1008.