Chittagong has been a seaport since ancient times. The region was home to the ancient Bengali Buddhist Samatata and Harikela states. It later fell under of the rule of the Gupta Empire, the Pala Empire and the Vesali kingdom of Arakan till the 7th century. Arabs traded with the port from the 9th century AD. An account by historian Lama Taranath has revealed a Buddhist king Gopichandra had his capital at Chittagong in the 10th century, and according to Tibetan tradition, Chittagong was the birthplace of 10th century Buddhist Tantric Tilayogi. In the Fourteenth Century, explorer Ibn Battuta passed through Chittagong during his travels.
Sultan Fakhruddin Mubarak Shah of Sonargaon conquered Chittagong in 1340 AD. Sultan Giasuddin Mubarak Shah constructed a highway from Chittagong to Chandpur and ordered the construction of many lavish mosques and tombs. After the defeat of Mahmud Shah in the hands of Sher Shah in 1538, the Arakanese Kingdom of Mrauk U regained Chittagong. From this time onward, until its conquest by the Mughals, this region was under the control of the Portuguese and the Magh pirates (a notorious name for Arakanese) for 128 years.
The Mughal commandar Shayestha Khan and his son Buzurg Umed Khan expelled the Arakanese from the area in 1666 and established Mughal rule there. After the Arakanese expulsion, Islamabad, as the area came to be known, made great strides in economic progress. This can mainly be attributed to an efficient system of land-grants to selected diwans or faujdars to clear massive areas of hinterland and start cultivation. The Mughals, similar to the Afghans who came earlier, also built mosques having a rich contribution to the architecture in the area. What is called Chittagong today also began to have improved connections with the rest of Mughal Bengal. The city was occupied by Burmese troops shortly in First Anglo-Burmese War in 1824 and the British increasingly grew active in the region and it fell under the British Empire. The people of Chittagong made several attempts to gain independence from the British, notably on 18 November 1857 when the 2nd, 3rd, and 4th companies of the 34th Bengal Infantry Regiment stationed at Chittagong rose in rebellion and released all the prisoners from jail but were suppressed by the Kuki scouts and the Sylhet Light Infantry (10th Gurkha Rifles).
Chittaong grew at the beginning of the twentieth century after the partition of Bengal and the creation of the province of Eastern Bengal and Assam. The construction of the Assam Bengal Railway to Chittagong facilitated further development of economic growth in the city. However, revolutionaries and opposition movements grew during this time. Many people in Chittagong supported Khilafat and Non-Cooperation movements.