Thang Long was founded in the 11th century by Lý Thái Tổ, the first emperor of the Lý dynasty. The city was built on the site of an earlier city, which had been the capital of the kingdom of Văn Lang. Thang Long was designed according to the principles of Chinese geomancy, with its streets and buildings arranged in a grid pattern. The city was also surrounded by a wall, which was about 10 kilometres (6.2 mi) in length.
Thang Long was a prosperous and populous city during the Lý and Trần dynasties. The city was home to a large number of temples, palaces, and other public buildings. It was also a major center of trade and commerce. In the 15th century, Thang Long was captured by the Chinese Ming dynasty. The city was renamed Beijing (北京, "northern capital"), and it remained under Chinese control for 20 years.
In 1428, Thang Long was liberated from Chinese rule by the Lê dynasty. The city was renamed Dong Kinh (東京, "eastern capital"), and it continued to be the capital of Đại Việt until the 19th century. In 1831, the capital of Đại Việt was moved to Huế. Thang Long was renamed Hanoi (河內, "inner river"), and it became a provincial city.
In 1945, Hanoi became the capital of the Democratic Republic of Vietnam. The city has been the capital of Vietnam ever since.
The name "Hanoi" is derived from the Vietnamese words "hà" (河), meaning "river", and "nội" (內), meaning "inner". The name "Thang Long" is derived from the Chinese characters "昇龍", meaning "ascending dragon".