The Ghaznavid dynasty (Persian: غزنویان Ġaznaviyān) was a Persianate Muslim dynasty of Turkic mamluk origin. It ruled the Ghaznavid Empire or the Empire of Ghazni from 977 to 1186, which at its greatest extent, extended from the Oxus to the Indus Valley. The dynasty was founded by Sabuktigin upon his succession to the rule of Ghazna after the death of his father-in-law, Alp Tigin, who was an ex-general of the Samanid Empire from Balkh.
Sabuktigin's son, Mahmud of Ghazni, expanded the Ghaznavid Empire to the Amu Darya, the Indus River and the Indian Ocean in the east and to Rey and Hamadan in the west. Under the reign of Mas'ud I, the Ghaznavid dynasty began losing control over its western territories to the Seljuk Empire after the Battle of Dandanaqan in 1040, resulting in a restriction of its holdings to modern-day Afghanistan, Pakistan and Northern India.