Indian military history records that from ancient times the elephant was the main instrument of the army as a weapon of war. Indian kings had large corps of elephants who led the charge in a battle. In 326 BC at the battle of Hydespes, when Raja Porus met Alexander the great, the elephant was the main weapon of assault of the Indian king. Porus more than anything held his ground against Alexander and in great measure it was due to his elephant corps. This system of reliance on the elephant continued for another 1800 years, despite a series of defeats at the hands of the Muslim invaders like Mohammed Qasim and Ghori. Even the Muslim kings who came to India,were overawed by the elephants and readily formed elephant corps for their army. Thus the Lodhi rulers of north India and Delhi had large number of elephants in their army. Ibrahim Lodhi was the ruler of Delhi at that time, but many in his family and court were eager to dethrone him.
Babur invaded India in 1525. He was running away from his uncles who had seized his kingdom. He was a Tartar and traced his lineage to Timur, who had sacked Delhi in 1398 from his fathers side and Genghis Khan from his mothers side. Babur was looking for a kingdom to rule as he had been ousted from his own kingdom. There are reports which show that some members of the close circle of Ibrahim Lodhi invited Babur to invade India. However Ibrahim Lodhi had no strategic sense. Instead of going and facing Babur at the gates of Hindu Kush, he just waited for Babur and decided to confront him at Panipat. this was a great strategic mistake.
Babur reached Panipat with a force estimated between 13000-15000 men, the majority of who were cavalry. Thus he had the advantage of flexibility and speed. In contrast the force of Lodhi numbered between 45000-50000 and a core of over 200 elephants, but hardly any cavalry. Most of his force consisted of infantry and he was confident with a massive elephant charge he would carry the day. In effect the battle was now between the cavalry of Babur and the army of elephants of Ibrahim Lodhi.
Babur had a secret weapon up his sleeve and that was a force of about 25-30 cannons which he had got from the Turks. On the morning of that fateful day both the armies faced each other at Panipat. Ibrahim Lodhi started the battle with an elephant charge. At the same time the guns of Babur opened fire. The guns were not very effective, but they created a lot of noise and smoke and this frightened the elephants who turned back and in the mood they were attacked the infantry of Ibrahim Lodhi. There was total confusion and the army of Lodhi lost heart. We know now that a substantial part of the Lodhi force defected to Babur and Lodhi who had come to battle on an elephant was badly injured and left to die on the battlefield.
Babur now ordered the cavalry charge and the swift horsemen followed the retreating army of Lodhi and thousands were massacred. By noon all was over and Babur was the victor. As per some reports he got all the troops who had defected to him executed, as he felt that a soldier who deserts his master once may do it again. Babur also beheaded another 15000 captured soldiers and made a huge victory pyramid of the skulls of the vanquished army. This is mentioned in the Baburnama.
Two factors stand out in this battle. Firstly the role of the cannons and secondly the charge of Babur's cavalry. Only if Lodhi had an equal complement of cavalry, there could have been a better match. In retrospect the cavalry of Babur was instrumental in sealing the victory. Babur now won a kingdom for himself, as he became the ruler of Delhi.