The existence of urbanised settlements in the area that is now Dhaka dates from the 7th century. The city area was ruled by the Buddhist kingdom of Kamarupa and the Pala Empire before passing to the control of the Hindu Sena dynasty in the 9th century. Many believe that the name of the city was derived after the establishment of the Goddess Dhakeshwari's temple by Ballal Sena in the 12th century.
Dhaka and its surrounding area was identified as Bengalla around that period. The town itself consisted of a few market centers like Lakshmi Bazar, Shankhari Bazar, Tanti Bazar, Patuatuli, Kumartuli, Bania Nagar and Goal Nagar. After the Sena dynasty, Dhaka was successively ruled by the Turkish and Afghan governors descending from the Delhi Sultanate before the arrival of the Mughals in 1608. The development of townships and a significant growth in population came as the city was proclaimed the capital of Bengal under Mughal rule in 1608.
Mughal subahdar Islam Khan was the first administrator of the city. Khan named the town "Jahangir Nagar" (City of Jahangir) in honour of the Mughal emperor Jahangir, although this name was dropped soon after Jahangir's death. The main expansion of the city took place under Mughal general Shaista Khan. The city then measured 19 by 13 kilometres (12 by 8 mi), with a population of nearly a million people. The city passed to the control of the British East India Company in 1765 after the Battle of Plassey.
The city's population shrank dramatically during this period as the prominence of Kolkata rose, but substantive development and modernisation eventually followed. A modern civic water supply system was introduced in 1874 and electricity supply launched in 1878. The Dhaka Cantonment was established near the city, serving as a base for British and Indian soldiers. During the abortive Partition of Bengal in 1905, Dhaka was declared to be the capital of the newly established state of Eastern Bengal and Assam, but Bengal was reunited in 1911.
Following the partition of India in 1947, Dhaka became the capital of East Bengal as a part of the new Muslim state of Pakistan. The city witnessed communal violence that left thousands of people dead. A large proportion of the city's Hindu population departed for India, while the city received hundreds of thousands of Muslim immigrants. The city's population rose dramatically in a very short period of time, which created severe shortages and infrastructural problems.
As the centre of regional politics, Dhaka saw an increasing number of political strikes and incidents of violence. The adoption of Urdu as the sole official language of Pakistan led to protest marches involving large crowds. Known as the Bengali Language Movement, the protests resulted in police firing which killed students who were demonstrating peacefully. Throughout the 1950s and '60s, Dhaka remained a hotbed of political activity, and the demands for autonomy for the Bengali population gradually gained momentum.
The 1970 Bhola cyclone devastated much of the region, killing an estimated 500,000 people. More than half the city of Dhaka was flooded and millions of people marooned. With public anger growing against ethnic discrimination and poor cyclone relief efforts from the central government, Bengali politician Sheikh Mujibur Rahman held a nationalist gathering on March 7, 1971 at the Race Course Ground. An estimated one million people attended the gathering, leading to the March 26 declaration of Bangladesh's independence.
In response, the Pakistan Army launched Operation Searchlight, which led to the arrests, torture and killing of hundreds of thousands of people, mainly Hindus and Bengali intellectuals. The fall of the city to the Indian Army on December 16 marked the creation of the independent state of Bangladesh. The post-independence period has seen a rapid and massive growth of the city population, attracting migrant workers from rural areas across Bangladesh. A real estate boom has followed the expansion of city limits and the development of new settlements such as Gulshan, Banani and Motijheel.