The history of this beautiful fort in Madhya Pradesh goes well back, past the 5th c. CE. when the Guptas were ruling. The hill on which the fort stands was variously known as Gopachala/Gopagiri/Gopadri, meaning the shepherd's hill, and is a 300 feet high rocky outcrop that is long and narrow, and gives a bird's eye view of the surroundings.
In the 6th c. CE two Huns named Toramana and Mihirakula ruled the area after defeating the imperial Guptas. Few years later however, Yasodharman defeated Mihirakula, and established his rule. Later the fort area went under the control of Emperor Harsha of Kanuaj. The next ruler of importance, was Raja Mihira Bhoja Deva, and his dynasty held power until the Kachhwahas came took over the fort and adjoining areas around it. It is locally believed that the fort's foundations were laid at this time under the Kachhwaha king Suraj Sen, who was cured of leprosy after drinking water from a spring near the Suraj Kund under ministrations of a sage named Gwalipa. In 1129 CE the Pratiharas (another Rajput dynasty) usurped the throne, only to lose it to Qutbddin Aibak in 1196 CE. The Pratiharas won back the fort and it remained under their rule until 1232 CE when Iltutmish captured it, after eleven months long siege, killing 700 prisoners right before his tent and destroying many of the temple structures inside the fort. This was also the first time when Jauhar occurred inside the Gwalior fort premises. The fort remained with the Delhi sultanate until 1398 CE, when the Tomars took control over it. The Tomars ushered in the golden era of the Gwalior fort and gave the region a certain degree of economic prosperity and stability. It was during the Tomars' rule that many of the beautiful Jain sculptures were carved inside the fort premises, likely at the behest of some Jain merchant prince.
The most famous ruler of the Tomar dynasty was Raja Man Singh who built the beautiful Man Singh palace also known as Man mandir, and the Gujari mahal for his queen Mrigyanayani, the later being famous for starting the Gwalior School of Music that produced some of the best musicians of the era, including Tansen. After the death of Raja Man Singh in 1517 CE, the fort was taken over by Ibrahim Lodi, and from him it went to Babar, who left behind his mark by ordering the destruction of the Jain murtis; however his orders were only partly carried out owing to the massive size of the murtis. Thereafter, the fort remained with the Mughals, with a short break of 15 years when Sher Shah Suri overthrew Humayun. Akbar turned this fort into a political prison and for the next two centuries the fort walls witnessed many terrible deaths of Mughal princes and other state prisoners.