Mahamud of Ghazni was son of Subuktgeen who came into power in 971 and reigned till 1030 AD. The first conflict was with Jayapala. After Jayapala committed suicide, his son Anandpala prepared an alliance with 6 rulers of Ujjain, Gwalior, Kalinjar, Kannauj, Delhi and Ajmer). This was known as Rajput Confederacy. The combined army of the Rajput Confederacy met in 1008 near Peshawar. The Rajput army was initially victorious but an elephant of Anandapala began to run away from the battle field. There was a stampede in the Rajput army and Mahmud won this fierce battle. He was now undisputed ruler of Punjab, Multan and Sindh.
Next raid of greedy Mahmud was on Nagarkot in 1009. The Hindus could not resist him and were looted and plundered. In 1011 he attacked and sacked Thaneshwar. In 1017 he looted and plundered Kannauj, Meerut, Mathura and while moving back along with heavy booty and tributes.
In 1021 the Mahmud attacked the last Shahi King Trilochanpala. The defeated Hindu king fled to Ajmer. Mahmud appointed first Muslim Governor in the east of Indus River.
Trilochanpala was later assassinated by his own people in 1023 AD. In 1024 Mahmud once again raided India. This time he sacked Ajmer, Kalinjar, Gwalior and Finally Somnath. The temple was destroyed. The Lingam was hammered and destroyed and its pieces were carted back to Ghazni where a Jama Masjid was built. He returned via Thar Desert to avoid the armies of Ajmer, though the Jats confronted him en route. During his last invasion he got Malaria and died in 1030 AD.
Objectives of Invasion on India
The main objective of Mahmud Ghaznavi’s invasion was the wealth of the Indians. But being an ardent Sunni Muslim, he was called the "Idol Breaker" and eagerly destroyed the temples of Jwalamukhi, Kangra, Mathura, Somnath etc. Each time he returned with enormous wealth but it is clear that there was no permanent impact of his attacks on India.
Why Rajputs failed?
The Rajputs, though patriotic, Courageous and zealous were suffering from the political myopia and could not estimate the dangers coming their way. They adopted and followed the epic era rules and customs of war such as not attacking the fleeing enemy, not attacking the enemy with no arms etc. The invaders took advantages of this lack of political foresight of the Rajputs and the result was that within a century, all the Hindu dynasties of the country were swept away by the torrent of the Muslims.