Mahmud Gaznavi attacked Rajyapala who submitted to him. Ganda and his other friendly kings did not like it. The kings of Ujjain, Gwalior, Kannauj, Delhi, Ajmer and Ganda made a confederation under the generalship of Anandapala and sent their army to face Mahmud Gaznavi. But the elephant of Anandapala became out of control in the battlefield, on account of which the Rajput army also stopped fighting and threw off their arms.
When Pratihara king submitted to Mahmud Gaznavi, Ganda sent his son Vidyadhar to punish Rajyapala. Rajyapala was killed and Trilochanapala was declared as the king of Kannauj. Mahmud was enraged to hear this incident and attacked Ganda in 1012 A.D. Ganda was confused to see the big army of Mahmud and fled away from the battlefield. Three years after this incident Mahmud again attacked Chandel kings and conquered the forts of Gwalior and Kalanjar. Ganda had to submit to Mahmud Gaznavi who returned his kingdom thereafter.