Medieval period
After the fall of the Kingdom of Panchala, the city was under the rule of local rulers.
According to British historian Matthew Atmore Sherring the district of Bareilly was formerly a dense jungle inhabited by a race of Ahirs and was called Tappa Ahiran.
In 1623 two Afghan brothers of the Barech tribe, Shah Alam and Husain Khan, settled in the region, bringing with them a number of other Pashtun settlers. The Rohilla Daud Khan was awarded the Katehr region in the then northern India by Mughal emperor Aurangzeb Alamgir (ruled 1658–1707) to suppress Rajput uprisings, which had afflicted this region. Originally, some 20,000 soldiers from various Pashtun Tribes (Yusafzais, Ghoris, Lodis, Ghilzai, Barech, Marwat, Durrani, Tanoli, Tarin, Kakar, Khattak, Afridi and Baqarzai) were hired by Mughals to provide soldiers to the Mughal armies and this was appreciated by Aurangzeb Alamgir, an additional force of 25,000 men was given respected positions in Mughal army. However most of them settled in the Katehar region during Nadir Shah's invasion of northern India in 1739 increasing their population up to 100,0000. Due to the large settlement of Rohilla Afghans, the Katehar region gained fame as Rohilkhand.
Meanwhile, Ali Mohammed Khan (1737–1749), captured the city of Bareilly and made it his capital, later uniting the Rohillas to form the state of 'Rohilkhand', between 1707 and 1720, making Bareilly his capital. According to 1901 census of India, the total Pathan population in Bareilly District was 40,779, out of a total population of 1,090,117. Their principal clans were the Yusafzais, Ghoris, Lodis, Ghilzai, Barech, Marwat, Durrani, Tanoli, Tarin, Kakar, Khattak, Afridi and Baqarzai. Other important cities were Rampur, Shahjahanpur, Badaun, and others.
Ali Muhammad was succeeded by Hafiz Rahmat Khan Barech (1749–1774), whom he appointed as the regent of Rohilkhand on his deathbed. Hafiz Rahmat Khan Barech extended the power of Rohilkhand from Almora in the North to Etawah in the South-West.
The term Rohilla is derived from the Pashtu Roh, meaning mountain, and literally means a mountain air, and was used by the Baluch and Jats of the Derajat region to refer to the Pashtun mountains tribes of Loralai, Zhob and Waziristan regions. The Rohillas and are men of a taller stature and a fairer complexion than the general inhabitants of the district. The Muslims in the area are chiefly the descendants of Yousafzai Afghans tribe of Pashtuns, called the Rohilla Pathans of the Mandanh sub-section, (but other Pashtuns also became part of the community), who settled in the country about the year 1720. Rohilla's Sardar like Daud Khan, Ali Muhammad Khan, and the legendary Hafiz Rahmat Khan Barech were from the renowned Afghan tribe the Barech, who were originally from the Kandahar Province of Afghanistan. In Uttar Pradesh, it was used for all Pashtuns, except for the Shia Bangashes who settled in the Rohilkhand region, or men serving under Rohilla chiefs. Rohillas were distinguished by their separate language and culture. They spoke Pashto among each other but gradually lost their language over time and now converse in Urdu.
Bishop Heber described them as follows – "The country is burdened with a crowd of lazy, profligate, self-called sawars (cavaliers), who, though many of them are not worth a rupee, conceive it derogatory to their gentility and Pathan blood to apply themselves to any honest industry, and obtain for the most part a precarious livelihood by sponging on the industrious tradesmen and farmers, on whom they levy a sort of blackmail, or as hangers-on to the wealthy and noble families yet remaining in the province. These men have no visible means of maintenance, and no visible occupation except that of lounging up and down with their swords and shields, like the ancient Highlanders, whom in many respects they much resemble."
Rohilkhand (under Hafiz Rahmat Khan Barech) was on the winning side at the Third Battle of Panipat of 1761 and successfully blocked the expansion of the Maratha Empire into north India. In 1772 Rohilkhand was invaded by the Marathas; however the Nawabs of Awadh came to the aid of the Rohillas in repulsing the invasion. After the war Nawab Shuja-ud-Daula demanded payment for their help from the Rohilla chief, Hafiz Rahmat Khan Barech. When the demand was refused the Nawab joined with the British under Governor Warren Hastings and his Commander-in-Chief, Alexander Champion, to invade Rohilkhand. Hafiz Rahmat Khan Barech was killed in the ensuing battle at Miranpur Katra in 1774.
Nawab Saadat Ali Khan surrendered Rohilkhand to the East India Company by the treaty of 10 November 1801.
During this period too, Bareilly retained its status as a mint. Emperor Akbar and his descendants minted gold and silver coins at mints in Bareilly. The Afghan conqueror Ahmed Shah Durani too minted gold and silver coins at the Bareilly mint.
During the time of Shah Alam II, Bareilly was the headquarters of Rohilla Sardar Hafiz Rehmat Khan and many more coins were issued. After that, the city was in possession of Awadh Nawab Asaf-ud-Daulah. The coins that he issued had Bareilly, Bareilly Aasfabad, and Bareilly kite and fish as identification marks. After that, the minting of coins passed on to the East India Company.
The Rohillas, after fifty years' precarious independence, were subjugated in 1774 by the confederacy of British troops with the Nawab of Oudh's army, which formed a charge against Warren Hastings. Their territory was in that year annexed to Oudh. In 1801 the Nawab of Oudh ceded it to the Company in commutation of the subsidy money.