Harald Tambs-Lyche believes that there is evidence, based on myths, that a Chudasama kingdom existed at Junagadh in the Saurashtra region of Gujarat.The dynasty is traditionally said to have been founded in 875 CE and around 1030 received assistance from members of the Ahir community in order to restore its power following a conquest of the kingdom by the king of Gujarat.Old rock-cut Buddhist "caves" in this area, dating from well before 500 CE, have stone carvings and floral work.
When the Portuguese took over the ports of Diu and Daman in the 16th century, a fifteen-foot cannon, made in Egypt in 1531, was abandoned at Uperkot Fort by a Turkish admiral opposing the Portuguese forces at Diu. The Anthropological Survey of India, which relies heavily on sources compiled during the period of the British Raj, notes that they are "an offshoot of the Samma tribe, who entered India during the 7th or 8th century and are found in Kachchh, Junagadh and Jamnagar districts." They claim to be originally of the Yadu clan or Yadava from Sindh .
Mahmud Begada (Mahmud Shah I) invaded Junagadh in 1467.
The city was annexed to the Gujarat Sultanate; the city foundation was laid for Mahmudabad in 1497.
The Chudasamas are sometimes referred to as the Ahirani Ranis, and Tambs-Lyche says that, "The structure of the Chudasama state , seems to have been an alliance between a small royal clan later to be classified as Rajputs and the Ahir tribe."According to the historical past also an Ahir sepoy of Chudasama rulers Devayat Bodar whose wife saved the Chudasama descendant from Bhimdev Chaulukya , sacrificing her off spring like Panna Dhai , that's why today also Chudasama are known as Bhanja (Nephews) of Ahirs .
The last of these kings was Mandlik Chudasama then Mahmud Begarha, who also annexed the state .
The fort was besieged 16 times over an 800-year period. There is an inscription with fourteen Edicts of Ashoka on a large boulder within 2 kilometres (1.2 mi) of Uperkot Fort.