The Ghaznavid Dynasty was founded after the Turk slaves reached higher posts, such as commander-in-chiefs, in the Samanid court; they then took over the state of Khorasan. The real founder of the Ghaznavid Dynasty is, in fact, Sabuktigin. It was in his time that the Ghaznavid sovereignty expanded. Mahmud Ghazni was Son of Sabuktigin, the founder of Ghazni dynasty & Turkish slave commander.
In all Mahmud Ghazni invaded India 17 times during AD 1000–1026.Mahmud Ghazni first encountered the Hindushai ruler, Jaipal in AD 1001. In the years AD 1004–06 Mahmud Ghazni attacked the rulers of Multan. Soon Punjab also passed into the hands of the Ghaznavids. Between AD 1014–1019, Mahmud enriched his treasury by looting the temples of Nagarkot, Thanesar, Mathura and Kanauj.
The attack against Nagarkot in AD 1008 has been described as his first great triumph. In AD 1025, Mahmud embarked on the most ambitious Indian campaign, the attack on the Somnath temple in Saurashtra. Mahmud captured the city after grim struggle in which more than 50,000 defenders lost their lives. Mahmud left Somnath after a fortnight when he came to know that the Gujarat king Bhima-I had completed preparations to confront him. His attacks on India were an attempt to fulfil his ambi- tion to make Ghazni the formidable power in the politics of Central Asia. Mahmud’s raids into India were only to acquire the famous wealth of India. This wealth would help him to consolidate his vast rule in Central Asia. He did not wish to establish an empire in India. The Ghaznavids had their control on parts of Punjab and Sind which continued till AD 1135. However his invasions exposed the weak defence of Indian kingdoms. They also opened possibility of attacks in future by the Turks.