Skip to Content

Who defeated Ghazni 17 times?

The defeat of Ghazni 17 times refers to an enemy who repeatedly defeated the Ghaznavid ruler Mahmud of Ghazni in battle during the early 11th century. Mahmud of Ghazni was a powerful ruler of the Ghaznavid Empire which ruled parts of Central Asia, Iran and northern India between the 10th and 12th centuries. He conducted numerous military campaigns into India, conquering areas of the northwestern part of the subcontinent. However, during these Indian campaigns, he suffered several defeats at the hands of a determined foe.

Mahmud of Ghazni

Mahmud of Ghazni was the most prominent ruler of the Ghaznavid dynasty which ruled an empire extending from eastern Iran to the Punjab between 977 and 1186 CE. Mahmud turned the small principality of Ghazni into a great empire by conducting relentless military campaigns against his neighbours.

In 1001 CE, Mahmud defeated the Shahis who ruled parts of northwestern India and annexed their kingdom to his empire. This brought him to the frontiers of the Indian subcontinent. Over the next two decades, Mahmud led numerous raids into northern India, plundering wealthy temples and cities like Nagarkot, Thanesar, Mathura and Kanauj. He deputed his most successful general Aytigin to lead expeditions deep into western and central India. At its peak, Mahmud’s empire encompassed an area stretching from northeastern Iran to the Punjab in India.

Mahmud’s repeated invasions of India were intended to collect booty and plunder the wealthy temples of northern India. The Indian historian Upendra Thakur describes him as “an insatiable invader and an intrepid marauder.” The raids also opened up India’s political divisions and weaknesses which Mahmud sought to exploit. He maintained a large, well-trained and effective cavalry force which enabled him to conduct swift strikes into the subcontinent.

Defeats at the Hands of the Indians

While Mahmud’s invasions brought him great wealth and prestige, he also suffered several reversals at the hands of determined Indian kings who opposed his incursions. These defeats highlighted that Mahmud’s position in India was not entirely secure despite his fearsome reputation.

Based on accounts of medieval Persian historians like Al-Utbi and Ferishta, Mahmud was defeated at least 17 times by different Indian kings over the course of his campaigns in the subcontinent. Some of these kings managed to repel not just one but several invasions by Mahmud. The most prominent among them was the Shahi ruler Anandapala and the Chandela ruler Vidyadhara.


The ruler of the Kabul Shahi dynasty, Anandapala, inflicted several defeats on Mahmud. He was the son of Jayapala who had suffered a crushing defeat previously at Mahmud’s hands. This had forced Jayapala to pay a heavy ransom and cede significant territories to Mahmud. After Jayapala’s death, Anandapala became the Shahi king in AD 1001 and ruled from his capital at Waihind (modern Ohind in Punjab, Pakistan).

When Mahmud invaded the Shahi kingdom again in AD 1010, Anandapala repulsed the attack despite being outnumbered. Mahmud returned the next year but was forced to retreat once more by Anandapala. The Shahi king managed to defeat Mahmud a total of eight times over a decade, according to medieval Persian accounts. These defeats delayed Mahmud’s conquest of the Shahi territories for several years. Anandapala also rallied other Punjab chiefs like the ruler of Delhi, against Mahmud.


The Chandela king Vidyadhara was another ruler who inflicted several defeats on Mahmud. He ruled the kingdom of Jejakabhukti which lay to the south-east of Delhi. Its capital was Mahoba (in modern Uttar Pradesh).

When Mahmud first raided the Chandela domains in AD 1018, he managed to sack the fortress of Vidyadhara at Kalanjar. But the Chandela king himself inflicted a crushing defeat on the invader, forcing him to retreat. Mahmud had to flee without accomplishing anything. He returned in AD 1022 with a stronger force but once again suffered a defeat by Vidyadhara. The Chandela king was aided by allied Hindu kings in these battles including the Paramaras of Malwa and the Kalachuris of Tripuri.

Vidyadhara inflicted a total of nine defeats on Mahmud over the space of five years, according to medieval Persian chroniclers like Ferishta. Some modern historians also concur that Mahmud was defeated multiple times by Hindu kings at strategic frontier kingdoms like those of the Shahis and the Chandelas. These defeats acted as a deterrent against Mahmud establishing a permanent presence across northern India.

Reasons for Mahmud’s Defeats

Mahmud’s string of defeats against the Shahi and Chandela kingdoms, despite his superior strength, can be attributed to several factors –

Motivation of Defending Kings

The Indian kings like Anandapala and Vidyadhara were fighting on their home turf to defend their kingdoms and people. This motivation likely gave them an edge over the invading army.

Tactical Errors

Mahmud may have underestimated the military strength and motivation of the defending kings on some occasions, leading to tactical errors.

Alliances between Indian Kings

The rulers of adjoining kingdoms often united against Mahmud which amplified their cumulative strength. Anandapala and Vidyadhara rallied allies to their cause.

Tough Terrain

The retreating Indians drew Mahmud deeper into difficult hilly and forested terrain which was unfavourable for his cavalry-heavy troops.

Overextension of Supply Lines

As Mahmud advanced deeper into western and central India, his supply lines became overextended making his large army vulnerable.

Heat and Disease

The extreme heat and endemic diseases of India took a toll on Mahmud’s forces which were more acclimatized to the cooler climate of Central Asia.

Thus, despite being a consummate military commander, Mahmud’s complex encounters in India exposed his army’s weaknesses against resolute foes fighting on home turf. These defeats did not stop Mahmud from raiding India but made it difficult for him to permanently occupy territory across the northwestern frontiers.

Impact on Mahmud’s Indian Campaigns

While Mahmud’s repeated invasions caused devastation across northern India, his ambitions were thwarted to an extent by the staunch resistance of kings like Anandapala and Vidyadhara. Some impacts of their defiant stand against the invader –

  • Mahmud was unable to make deep inroads into central and western India despite raiding up to Gujarat and Gwalior.
  • The North-West frontier kingdoms remained independent under rulers like Anandapala for longer, blocking Mahmud’s eastern expansion.
  • The defeats diluted Mahmud’s reputation of invincibility, compelling him to extract tribute instead of outright conquest.
  • His son Masud could not retain control over the Punjab after Mahmud’s death, which slipped out of Ghaznavid control.

Thus, while Mahmud managed to extract enormous wealth from India by plundering wealthy temples, his strategic ambitions were partly frustrated by the dogged resistance of frontier kings like the Shahis and Chandelas. The defeats showed the limitations of Mahmud’s essentially predatory expeditions into India.


The repeated defeats suffered by Mahmud of Ghazni at the hands of Indian rulers like Anandapala and Vidyadhara highlight that his invasions were not entirely one-sided. The motivation of defending their homeland and people gave these kings a formidable edge. Mahmud’s overconfidence and tactical errors also contributed to his reversals. The inhospitable terrain and climate weakened his forces during retreats. While Mahmud succeeded in raiding wealthy Indian cities, his strategic ambitions were partly thwarted due to the fierce resistance of the Indians. Thus, the hardy defence put up by the Shahis and Chandelas against Mahmud’s invasions partly redeemed Indian military prestige despite the damage inflicted by the invader.