Early History of Bareilly began from Indian epic, Mahabharata. Later during the Sixteen Mahajanapadas rule in India, Panchala came as the seat of architectural skill and knowledge.
Bareilly in Mahabharata
Bareilly was the capital of the ancient kingdom of Panchala. The ancient fortress city of Ahicchattra in Bareilly served as a seat of the influential Empire. Panchala Kingdom occupied the region to the east of the Kuru Kingdom, i.e. between the Upper Himalayas and the Ganga River. Bareilly was divided into Northern Panchala and Dakshina-Panchala. The Northern Panchala had its capital at Ahicchattra, while Southern Panchala had its capital at Kampilya or Kampil in Farrukhabad district. King Drupada, whose daughter Draupadi was married to the Pandavas belonged to the Somaka clan. However, the Mahabharata and the Puranas consider the ruling clan of the northern Panchala as an offshoot of the Bharata clan and Divodasa, Sudas, Srinjaya, Somaka and Drupada (also called Yajnasena) were the most notable rulers of this clan. The Kshatriya Nairs is believed to be belonged to the Yajnasena clan and migrated from Ahi-Kshetra to Kerala, via Shimoga and Tulunadu.
Bareilly in 5th Century BC
The government in Panchala was engulfed in the growing Magadhan Empire after the battle with Sixteen Mahajanapadas. The first came under the Nandas and then under the Mauryas. The fall of the Mauryan Empire saw the emergence of numerous small and independent states in the whole Ganga River valley. It saw a remarkable revival in the fortunes of Panchala which once again came to occupy a very significant position in the history of north India. Panchala or Bareilly emerges at this time as one of the strongest powers in India. About 25 kings who have ruled during this period have left behind thousands of coins. During the period between the fall of the Mauryas and the rise of the Guptas, the Panchalas had two phases of power - first the pre Kushana phase i.e. from C-150 BC to AD 125 and secondly a short period of fifty years after the fall of the Kushanas, which ended in 350 BC when Panchala was assimilated in the Gupta empire by Samudragupta. Under the Guptas Ahichhatra was one of the provinces into which the Gupta Empire was divided. The Panchal coins were minted at Bareilly and the surrounding areas during 176 - 166 BC. Kushan Kings and Gupta kings established mints in the region and this status was retained till the Christian era.
Bareilly after Guptas
After the fall of the Gupta Empire in the latter half of the 6th century the district of Bareilly came under the domination of the Maukharis. Under the Emperor Harshavardhana, Panchala was the part of the Ahichhatra Bhukti. In the 6th century BC, the Panchala was among one of the Sixteen Mahajanapadas of India. The city was also influenced by Gautama Buddha and his followers. The remains of Buddhist monasteries at Ahichhatra are quite extensive. The folklore says that Gautama Buddha had once visited the ancient fortress city of Ahicchattra in Bareilly.
Bareilly under Jain Culture
The Jain Tirthankara Parshvanath is said to have attained Kaivalya at Ahichhatra. During Harshavardhana"s reign the Chinese pilgrim Hiuen Tsang also visited Bareilly about 635 AD. At that time, Bareilly included in the kingdom of Yashavarman (725 - 52AD) of Kannauj and after him the Ayodhya kings. Kannauj became the masters of the district for several decades. With the rise of the power of the Gurjara Pratiharas in the 9th century, Bareilly came under their sway. It continued under their subordination till the end of the 10th century. The decline of early history of Bareilly came with the attacks of Mahmud of Ghazni in 10th Century.