Anandapala/Anantpala was a Hindu Shahi King and the son of Indian ruler Jayapala. He was defeated by Mahmud Of Ghazni when his elephant suddenly took flight and turned the tide of the battle.
Prince Anandapala who ascended his father's throne (in about March/April AD 1002) already proved an able warrior and general in leading many battles prior to his ascension. According to 'Adáb al-Harb' (pp. 307–10) in about AD 990, it is written, "the arrogant but ambitious Raja of Lahore Bharat, having put his father in confinement, marched on the country of Jayapála with the intention of conquering the districts of Nandana, Jailum (Jehlum) and Tákeshar" (in an attempt to take advantage of Jayapala's concentrated effort with defence against the armies of Ghazni). "Jayapala instructed Prince Anandapala to repel the opportunist Raja Bharat. Anandapala defeated Bharat and took him prisoner in the battle of Takeshar and marched on Lahore and captured the city and extended his father's kingdom yet further."
However, during his reign as emperor many losses were inflicted on his kingdom by the Ghaznavids. During the battle of Chach between Mahmud and Anandapala, it is stated that "a body of 30,000 Gakhars fought alongside as soldiers for the Shahi Emperor and incurred huge losses for the Ghaznavids". However, despite the heavy losses of the enemy, he lost the battle and suffered much financial and territorial loss. This was Anandapala's last stand against Sultan Mahmud of Ghazni. He eventually signed a treaty with the Ghaznavid Empire in AD 1010 and shortly a year later died a peaceful death. R.C Majumdar (D.V. Potdar Commemoration Volume, Poona 1950, p. 351) compared him ironically to his dynastic ancient famous ancestor "King Porus, who bravely opposed Alexander but later submitted and helped in subduing other Indian rulers". And Tahqíq Má li'l-Hind (p. 351) finally revered him in his legacy as "noble and courageous" .
He was succeeded by his son Prince Trilochanpála who ascended his father's throne in about AD 1011.