Daud Khan Karrani, the Pathan Sultan of Bengal was defeated in 1576 by the troops of Mughal Emperor Akber of Delhi at the Battle of Rajmahal. But, the war continued between the Bengal Chieftains (Baro Bhuyan) and Delhi until 1605, when Mughal military Governor Shaikh Islam Khan won the war against the Pathan Chieftains.
During this long period of war, bloodsheds and anarchy, the Arakani (known as Moghs) captured not only the present day greater Chittagong Zilla, its domain also extended upto Barisal Zilla. All the islands in the BoB went under their domination. Chittagong region was always a point of tug of war among Bengal, Tripura and Arakan. This port City always changed hands.
When Shayesta Khan, the maternal uncle of Emperor Aurangzeb, became the Subedar of Bengal (can't remember the year) he drove away all the Mogh forces from the occupied territories and extended his domain upto Teknaf. Shayesta Khan renamed Chittagong as Islamabad. Chittagong and Teknaf remain a part of Bengal since that time, although the name Chittagong prevailed over Islamabad.