The existence of a settlement 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. The name of the city may have derived after the establishment of the Goddess Dhakeshwari's temple by Ballal Sena in the 12th century. The town itself consisted of a few market centres like Lakshmi Bazar, Shankhari Bazar, Tanti Bazar, Patuatuli, Kumartuli, Bania Nagar and Goal Nagar. After the Sena Empire, Dhaka was successively ruled by the Sultanate of Bengal as well as interruption of governors from the Delhi Sultanate before being taken over by the Mughals in 1608. The development of townships and housing has resulted into a significant growth in population came as the city was proclaimed the capital (Rajmahal) 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 one million people. British East India Company in 1765 gained right to collect revenue (Diwani right) and later took over governing in 1793 when Nawabs of Bengal were forced to abdicate all their authority over Bengal, Bihar & Orissa & the city passed on to total British control. The city's population shrank dramatically during this period as the prominence of Calcuttarose, 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 Bengali soldiers.
During the abortive Partition of Bengal in 1905, Dhaka was declared to be the capital of the newly established state of East Bengal and Assam, but Bengal was reunited in 1911. Following the Partition of India in 1947, Dhaka became the capital of East Pakistan. The city witnessed major communal violence following the partition of India. A large proportion of the city's Hindu population departed for India, while the city received a large influx of Muslims. As the centre of regional politics, however, 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 Pakistani police firing which killed a number of peaceful student demonstrators. Throughout the 1950s and 1960s, 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 was flooded and millions of people were marooned. With public anger growing against ethnic discrimination and poor cyclone relief efforts from the central government, Bengali politician BangabandhuSheikh Mujibur Rahman held a nationalist gathering on March 7, 1971 at Ramna Racecourse. 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 thousands of people. After nine months of bloody battle with Indian Army and Mitra Bahini, the Pakistani Army surrendered to the Indian Army on December 16 marking the end of the independence war of Bangladesh. As the nation's capital, Dhaka saw a rapid and massive growth of the city population in the post-independence period, as migrant workers from rural areas across Bangladesh moved to the city. The growth of commerce and industry along with the city's population has created further challenges to services and infrastructure. A real estate boom has followed the expansion of city limits and the development of new settlements such as Uttara,Mohammadpur, Bashundhara, Mirpur and Motijheel.