In June 1802 Nguyễn Phúc Ánh took control of Vietnam and proclaimed himself Emperor Gia Long. His rule was recognized by China in 1804. Gia Long consulted with geomancers to decide which was the best place for a new palace and citadel to be built. After the geomancers had decided on a suitable site in Huế, building began in 1804. Thousands of workers were ordered to produce a wall and moat, 10 kilometers long. Initially the walls were earthen, but later these earthen walls were replaced by stone walls, 2 meters thick.[citation needed]
The citadel was oriented to face the Huong River to the east. This was different from the Forbidden City in Beijing, which faces south. The Emperor's palace is on the east side of the citadel, nearest the river. A second set of walls and a second moat was constructed around the Emperor's palace. Many more palaces and gates and courtyards and gardens were subsequently added. The rule of the last Vietnamese Emperor lasted until the mid-1900s. At the time, the Purple Forbidden City had many buildings and hundreds of rooms. It suffered from termite and cyclone damage, but was still very impressive. Many bullet holes left over from the war can be observed on the stone walls.
In the early morning hours of January 31, 1968, as part of the Tet Offensive a Division-sized force of North Vietnamese Armyand Viet Cong soldiers launched a coordinated attack on Huế seizing most of the city. During the initial phases of the Battle of Hue, due to Huế's religious and cultural status, Allied forces were ordered not to bomb or shell the city, for fear of destroying the historic structures; but as casualties mounted in the house-to-house fighting these restrictions were progressively lifted and the fighting caused substantial damage to the Imperial City. Out of 160 buildings only 10 major sites remain because of the battle, such as the Thái Hòa and Cần Thanh temples, Thế Miếu, and Hiển Lâm Các. The city was made a UNESCO site in 1993. The buildings that still remain are being restored and preserved. The latest and so far the largest restoration project is planned to conclude in 2015